Welcome to ONOS’s documentation!¶
Contents:
arduino_handler module¶
arduinoserial module¶
conf module¶
This module is used to import all the configurations from the saved files at the onos startup
-
conf.
importConfig
()[source]¶ This function imports all the data and configurations from the files saved on storage memory.|br| The file are located in the config_files directory
-
conf.
newDefaultWebObj
(name)[source]¶ Return a new web_object given only its name, used to create new web_objects for exemple when a new zone is created
-
conf.
newDefaultWebObjBody
(name)[source]¶ Return a new web_object given only its name, used to create the zone html body object
-
conf.
newNodeWebObj
(name, objType, node_sn, pinList=[])[source]¶ Return a new web_object given its name,objType,node_sn,pinList used to create new web_objects for exemple when a new node is added
globalVar module¶
This module is imported from all the others and it stores the global variables and some global functions.
-
globalVar.
getErrorTimeString
()[source]¶ Called when an error occours ,return the current time and a progressive number of the error, incrementing the error_count. Used to send the error time and error_count to debug the software.
-
globalVar.
getListPinsConfigByHardwareModel
(hwName, pin_mode)[source]¶ Given hardware name and a pin mode , return a list containing the pin numbers that are configurated with that pin_mode
Parameters: - hwName –
The type of the hardware node for examples:
- ProminiA
- Plug6way
- RouterGL
- RouterGA
- RouterRB
- Any other hardware type added as hardwareModelDict key in globalVar.py
- pin_mode –
The pin mode you are searching for:
- sr_relay:
- Latch relay where the first pin in the tuple is set and the second is reset
- digital_output:
- Output digital pins
- digital_input :
- Input digital pins
- analog_input :
- Analog input
- servo_output :
- Servomotor control pin
- analog_output :
- Pwm output pin
- hwName –
-
globalVar.
getListUsedPinsByHardwareModel
(hwName)[source]¶ Given an hardware name return a list with all the pins used by a hardware model
Parameters: hwName – The type of the harware node for examples:
- ProminiA
- Plug6way
- RouterGL
- RouterGA
- RouterRB
- Any other hardware type added as hardwareModelDict key in globalVar.py
hw_node module¶
-
class
hw_node.
HwNode
(NodeSerialNumber, hwModel, address, node_fw)[source]¶ -
-
getHwType
()[source]¶ Return the node hardware type like:
- gl.inet_only
- arduino_promini
- rasberry_b_rev2_only
- arduino2009
-
getNodeAddress
()[source]¶ Return the node address , if the address is 0 then the node is the arduino over usb (todo)
-
getNodeFwVersion
()[source]¶ - Return a string containing the node firmware versionAn example is “5.14”
-
getNodeSectionMode
()[source]¶ Warning: Never used Return a list containing the node mode for each section (8 bit)(the section0 is relative to the first 8 pins , from pin 0 to pin 7) msb left(the section1 is relative to the pins from 8 to 15)(the section2 is relative to the pins from 16 to 23 )(the section3 is relative to the pins from 24 to 31)(the section4 is relative to the pins from 32 to 39 )(the section5 is relative to the pins from 40 to 47)(the section6 is relative to the pins from 48 to 55 )
-
getNodeSectionModeByPin
(pin)[source]¶ - Deprecated , not used anymore.
- Given a pin return the node mode for the section (8 bit) containing that pin.
-
getNodeSectionStatusByPin
(pin)[source]¶ Given a pin return a tuple with:
- The number of the section where the pin is located
- The the node status register for the section (8 bit) containing that pin
Structure:(the section0 is relative to the first 8 pins , from pin 0 to pin 7) msb left(the section1 is relative to the pins from 8 to 15)(the section2 is relative to the pins from 16 to 23 )(the section3 is relative to the pins from 24 to 31)(the section4 is relative to the pins from 32 to 39 )(the section5 is relative to the pins from 40 to 47)(the section6 is relative to the pins from 48 to 55 )
-
getNodeStatusList
()[source]¶ Warning: Never used
Return a list containing the node status for each pin.
-
getNodeTimeout
()[source]¶ - Return the time after which the node is declared inactive.So if getLastNodeSync() is greater than this self.timeout the node will be setted as inactiveself.timeout is readed from hardwareModelDict in globalVar.py
-
getSetupMsg
()[source]¶ Return a encoded string containing the setup mode for the node pins
I need to encode the pin setup in a sinmple and compact way. Here the protocol:
start with 's=' then add 9 bytes that rappresent the pin used (1 for pin used 0 for not used) after that 9 bytes that rappresent the digital pin setup from pin0 to pin 127 after that 9 bytes that tell arduino which pin to set as analog input after that 9 bytes that tell arduino which pin to set as pwm output after that 9 bytes that tell arduino which pin to set as servo output then 1 byte for future use , for now '#' example:"s=000000000000000000000000000000000000000000000#" the 0 are not 0 but the value corrisponding to ascii '0' total 48 byte
-
setNodeActivity
(value)[source]¶ Set the node activity status with the one given.
Parameters: value – - The value to set the node activity should be a integer of 0 or 1
- 0 If the node is inactive1 If the node is active
-
setNodeAddress
(address)[source]¶ - Set the node address with the string passedExample: “192.168.101.10”
-
setNodeAnalogInputStatusFromReg
(pin_number, low_byte, high_byte)[source]¶ - Given a pin number, and two bytes return the analog value in an single integer.Since arduino analogRead return a 10 bit analog value to send it I need to split it in two bytes (8 bit each)so arduino will send 2 bytes the low_byte and the high_byte , this function will rebuild the number from those two bytes
-
setNodeFwVersion
(nodeVersion)[source]¶ - Set the node firmware version with the given stringExample “4.15”
-
setNodeObjectAddress
(objectAddress, objectName)[source]¶ - Set the objectname to an address in the node
-
setNodePinMode
(pin, mode)[source]¶ - Given a pin number and a mode, set the pin modeThe options for mode are:
- “DOUTPUT” : digital output
- “AOUTPUT” : analog output
- “SOUTPUT” : servo motor output
- “DINPUT” : digital input
- “AINPUT” : analog input
-
setNodeSectionDInputStatus
(section_number, status_byte)[source]¶ - Set the node status pins of a section (8 bit) received from arduino.if the section status is different from the previous one then checkwhat pins changed and ask the webserver.py to change the webobj status of the relative pinsi don’t need a setNodeSectionDoutputStatus because the output status will be saved in the webobject status.
-
mail_agent module¶
Warning
-
mail_agent.
get_text
(msg)[source]¶ - Given the python mail object, parses email message text and return the mail text content.This doesn’t support infinite recursive parts, but mail is usually not so naughty.
-
mail_agent.
receiveMail
(mail_conf, imaplib, email)[source]¶ - This function connect to the mail server and download all the unread mails.Then if a mail contain the “onos=” string, the mail is added to a list which will be returned.Otherwise the mail is setted as unreaded in the mail server since is not a mail command for onos.To connect to the mail server the credential contained in mail_conf[] dictionary will be used.
Parameters: - mail_conf – The dictionary containing the mail credential,server address and smtp_port. (for now i tried only with gmail).
- imaplib – The imaplib library imported in globalVar.py
- email – The email library imported in globalVar.py
-
mail_agent.
sendMail
(receiver_user_mail, mailtext, mailSubject, mail_conf, smtplib, string)[source]¶ This function send a mail from the onos system.
Warning
If you want to send a mail, is better to add it to the mailQueue using: mailQueue.put({“mail_address”:m_sender,”mailText”:mailText,”mailSubject”:mailSubject}) In this way the mail will be sent after the previous ones are sent.
Parameters: - receiver_user_mail – The mail receiver
- mailtext – The mail text content
- mailSubject – The mail subject
- mail_conf – The dictionary containing the mail credential,server address and smtp_port. (for now i tried only with gmail).
- imaplib – The imaplib library imported in globalVar.py
- string – The string library imported in globalVar.py
node_query_handler module¶
-
node_query_handler.
handle_new_query_to_network_node_thread
()[source]¶ - This is a thread function that will run until every request in the queryToNetworkNodeQueue is done.It will get each query from queryToNetworkNodeQueue and call make_query_to_network_node()While the query is running the current_node_handler_list will contain the node serialnumber being queriedIn this way onos will avoid to make multiple simultaneos query to the same node.
-
node_query_handler.
handle_new_query_to_radio_node_thread
(serialCom)[source]¶ - This is a thread function that will run until every request in the queryToRadioNodeQueue is done.It will get each query from queryToRadioNodeQueue and call make_query_to_radio_node()While the query is running the current_node_handler_list will contain the node serialnumber being queriedIn this way onos will avoid to make multiple simultaneos query to the same node.
-
node_query_handler.
make_query_to_network_node
(node_serial_number, query, objName, status_to_set, user, priority, mail_report_list)[source]¶ - This function make a query to a powerline/ethernet node and wait the answer from the node.If the answer is positiveit will add to the priorityCmdQueue the command to change the web_object statusfrom pending to succesfully changed .If the answer from the node is an error or the node is not respondingthe query will be repeated x times before giving up.
-
node_query_handler.
make_query_to_radio_node
(serialCom, node_serial_number, query, number_of_retry_already_done)[source]¶ - This function make a query to a radio/serial node and wait the answer from the serial gateway.If the answer is positiveit will add to the priorityCmdQueue the command to change the web_object statusfrom pending to succesfully changed .If the answer from the node is an error or the node is not respondingthe query will be repeated x times before giving up.
pcduino module¶
router_handler module¶
-
class
router_handler.
RouterHandler
(hardwareModelDict, router_sn)[source]¶ -
-
composeChangeNodeOutputPinStatusQuery
(pinNumbers, node_obj, objName, status_to_set, node_serial_number, node_address, out_type, user, priority, mail_report_list)[source]¶ - Compose the correct query to change an output pin status on a remote node.The examples are:WARNING old documentation... todo update it“onos_r”+pin0+pin1+”v”+status_to_set+”s”+node_serial_number+”_#]” to set a sr_relay to status_to_set (0 or 1)onos_r0607v1sProminiS0001f000_#] pin6 and 7 used to control a s/r relay and turn it to set“onos_d”+pin_number+”v”+”00”+status_to_set+”s”+node_serial_number+”_#]” to set a digital pin to 0 or 1onos_d07v001sProminiS0001f000_#] set digital pin7 to 1“onos_s”+pin_number+”v”+status_to_set+”s”+node_serial_number+”_#]” to set a servopin from 0 to 180onos_s07v180sProminiS0001f000_#] set servo pin7 to 180“onos_a”+pin_number+”v”+status_to_set+”s”+node_serial_number+”_#]” to set a analogpin from 0 to 255onos_a05v100sProminiS0001f000_#] set analog pin5 to 100The node_serial_number is a hexadecimal number refering to the node serial numberThe node_address is a 3 byte ashii that rappresend the wireless node address(if the node is wireless,otherwise is ignored)the value must be between 0 and 255 it will be setted to “999” if is not used..
-
getProgressive_msg_id
()[source]¶ - Get a progressive id number to append it to the message in order to make it unique
-
outputWrite
(node_serial_number, pinList, statusList, node_obj, objName, previous_status, statusToSetWebObject, output_type, user, priority, mail_report_list)[source]¶
-
time_zone module¶
web_object module¶
-
class
web_object.
WebObject
(name, obj_type='b', start_status=0, styleDictionary={}, htmlDictionary={}, cmdDictionary={}, note=' ', hardware_pin=[9999], HwNodeSerialNumber=0, spareDict={})[source]¶ Bases:
object
-
HwNodeSerialNumber
¶
-
baz
¶
-
cmdDict
¶
-
getAttachedPinList
()[source]¶ - Return a list containing the object pins used in the hardware and if the webobject is a is a digital_objor an analog_obj or ...obj it will return the address of this object in the node,example: 0 means first object in the node, 1 means second object in the node ...
-
hardware_pin
¶
-
htmlDict
¶
-
name
¶
-
note
¶
-
object_type
¶
-
spareDict
¶
-
start_status
¶
-
styleDict
¶
-