![]() |
netmsgs
1.2.2
RoadNarrows Robotics Network Messaging Package
|
Public Member Functions | |
| def | __init__ (self, xml, pyfilepath, kwargs) |
| def | AugmentXmlDB (self) |
| def | Pass0 (self) |
| def | GenSource (self) |
| def | GenPrologue (self, fp) |
| def | GenMsgIds (self, fp) |
| def | GenFTDict (self, fp) |
| def | GenMsgDefSet (self, fp) |
| def | GenMsgDef (self, name, msgid, msgdef, dentry) |
| def | GenFieldDef (self, name, fid, fdef, dentry) |
| def | GenClass (self, fp) |
| def | GenEpilogue (self, fp) |
| def | WriteFTDict (self, fp) |
| def | WriteMsgDefSet (self, fp) |
| def | IsDeprecated (self, xdef) |
| def | BaseXType (self, ftype) |
| def | GetLineage (self, xtype) |
| def | EvalNum (sefl, args) |
| def | PrettyPrintTopComment (self, fp) |
| def | PrettyPrintMajorDivComment (self, fp, comment) |
| def | PrettyPrintMinorDivComment (self, fp, comment) |
| def | PrettyPrintBriefComment (self, fp, brief) |
Public Attributes | |
| mXml | |
| parsed xml instance | |
| mPyFilePath | |
| output .h header file name | |
| mDebug | |
| debug level | |
| mHungarian | |
| do [not] prepend RN Hungarian notation to message fields | |
| mPyBaseName | |
| output .h header file basename | |
| mFTDict | |
| extended field type dictionary | |
| mMsgDefSet | |
| message definition set dictionary | |
RoadNarrows Net Messages Python Source Generator Class.
The NetMsgsGenPy class reads the post-parsed database of a
NetMsgsXmlParser class instance and generates a Python .py file. The
python file expects the NetMsgs run-time python library.
Definition at line 79 of file NetMsgsGenPy.py.
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.__init__ | ( | self, | |
| xml, | |||
| pyfilepath, | |||
| kwargs | |||
| ) |
Initialize NetMsgsGenPy instance.
Parameters:
xml - NetMsgsXMLParser class instance.
pyfilepath - Generated output python file.
kwargs - Optional keyword arguments.
debug - Set debugging level: 0 == off, 1, 2, 3.
Definition at line 88 of file NetMsgsGenPy.py.
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.AugmentXmlDB | ( | self | ) |
Augument the XML database of parsed XML values with python generated parameters.
Definition at line 122 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.Pass0(), and NetMsgs.NetMsgsGenC.NetMsgsGenC.Pass0().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.BaseXType | ( | self, | |
| ftype | |||
| ) |
Returns the base XML field type for the given field type. Parameters: ftype - (Derived) field type. Return: Base field type.
Definition at line 640 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, and NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.EvalNum | ( | sefl, | |
| args | |||
| ) |
Evaluate a summation of terms.
Paramters:
args List of summation terms, with each term one of:
an equation, string, number
Examples:
5 -> '5'
5, '(3 * 10)' -> '35'
5, 'MY_MAX', '1*255' -> '300+MY_MAX'
Return:
Returns string of the evaluated results.
Definition at line 682 of file NetMsgsGenPy.py.
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenClass | ( | self, | |
| fp | |||
| ) |
Generate derived NetMsgs class. Parameters: fp - Opened output file pointer.
Definition at line 523 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintMajorDivComment(), and NetMsgs.NetMsgsGenC.NetMsgsGenC.PrettyPrintMajorDivComment().
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenEpilogue | ( | self, | |
| fp | |||
| ) |
Generate .py file epilogue. Parameters: fp - Opened output file pointer.
Definition at line 555 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, and NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef | ( | self, | |
| name, | |||
| fid, | |||
| fdef, | |||
| dentry | |||
| ) |
Generate field definition dictionary entry.
fielddef ::=
fielddef_simple
| fielddef_string
| fielddef_struct
| fielddef_vector
fielddef_simple ::=
fielddef_common ',' ['min:' m ',' 'max:' M ',' 'const:' C]
fielddef_string ::=
fielddef_common ',' ['const:' C]
fielddef_struct ::=
fielddef_common ',' 'msgdef:' '{' msgdef '}'
fielddef_vector ::=
fielddef_common ',' 'vdef:' '{' fielddef '}'
fielddef_common ::=
'name:' name ',' 'fid:' fid ',' 'ftype:' ftype ',' 'max_count:' n
name ::= (* field string name *)
msgid ::= (* field id enumeration *)
ftype ::= (* field type code *)
max_count ::= (* number of vector items, string characters or 1 for
simpel types *)
Parameters:
name - Name keyword value.
fid - Field id keyword value.
fdef - XML field definition.
deentry - Output field definition entry.
Definition at line 395 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.BaseXType(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GetLineage(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mFTDict, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, and NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict | ( | self, | |
| fp | |||
| ) |
Generate field types dictionary.
genftdict ::=
ns+'ExtFieldTypes' '=' '{' ftdict '}'
ftdict ::=
ftdict_item
| ftdict ',' ftdict_item
ftdict_item ::=
ftid ':' '{' msgdef '}'
| ftid ':' '{' fielddef '}'
Parameters:
fp - Opened output file pointer.
Definition at line 248 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.BaseXType(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.IsDeprecated(), NetMsgs.NetMsgsGenC.NetMsgsGenC.IsDeprecated(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mFTDict, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintMajorDivComment(), NetMsgs.NetMsgsGenC.NetMsgsGenC.PrettyPrintMajorDivComment(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.WriteFTDict().
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef | ( | self, | |
| name, | |||
| msgid, | |||
| msgdef, | |||
| dentry | |||
| ) |
Generate message definition dictionary entry.
msgdef ::=
msgdef_common ',' 'fielddef:' '[' fdeflist ']'
msgdef_common ::=
'name:' name ',' 'msgid:' msgid ',' 'max_count:' n
fdeflist ::=
'{' fielddef '}'
fdeflist ',' '{' fielddef '}'
name ::= (* message string name *)
msgid ::= (* message id enumeration *)
max_count ::= (* number of fields in message definition *)
Parameters:
name - Name keyword value.
msgid - Message id keyword value.
msgdef - XML message definition.
deentry - Output message definition entry.
Definition at line 332 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.BaseXType(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GetLineage(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.IsDeprecated(), NetMsgs.NetMsgsGenC.NetMsgsGenC.IsDeprecated(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mFTDict, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, and NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDefSet().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDefSet | ( | self, | |
| fp | |||
| ) |
Generate message definition set.
genmsgdefset ::=
ns+'MsgDefSet' '=' '{' msgdefset '}'
msgdefset ::=
msgdef_item
| msgdefset ',' msgdef_item
msgdef_item ::=
msgid ':' '{' msgdef '}'
Parameters:
fp - Opened output file pointer.
Definition at line 293 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.IsDeprecated(), NetMsgs.NetMsgsGenC.NetMsgsGenC.IsDeprecated(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mMsgDefSet, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintMajorDivComment(), NetMsgs.NetMsgsGenC.NetMsgsGenC.PrettyPrintMajorDivComment(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.WriteMsgDefSet().
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgIds | ( | self, | |
| fp | |||
| ) |
Generate Message Id enumeration. Parameters: fp - Opened output file pointer.
Definition at line 210 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.IsDeprecated(), NetMsgs.NetMsgsGenC.NetMsgsGenC.IsDeprecated(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintMajorDivComment(), and NetMsgs.NetMsgsGenC.NetMsgsGenC.PrettyPrintMajorDivComment().
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenPrologue | ( | self, | |
| fp | |||
| ) |
Generate .py file prologue. Prologue includes core imports plus any prologue specified in the XML file. Parameters: fp - Opened output file pointer.
Definition at line 182 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, and NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource | ( | self | ) |
Generate python .py source file. Exceptions: Raises NetMsgError exception on error.
Definition at line 160 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenClass(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenEpilogue(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDefSet(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgIds(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenPrologue(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mPyFilePath, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintTopComment(), and NetMsgs.NetMsgsGenC.NetMsgsGenC.PrettyPrintTopComment().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GetLineage | ( | self, | |
| xtype | |||
| ) |
Get lineage of XML field type Parameters: xtype - XML field type Return: List of ancestors order from base to nearest to xtype.
Definition at line 660 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, and NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFieldDef(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.IsDeprecated | ( | self, | |
| xdef | |||
| ) |
Returns True (False) is definition is (not) deprecated. Parameters: xdef - XML ftypedef, msgdef, or fielddef XML specification. Return: True or False.
Definition at line 623 of file NetMsgsGenPy.py.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDef(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDefSet(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgIds().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.Pass0 | ( | self | ) |
Make initial pass through the XML database and augument with specific python information. No generated python code is written to file output.
Definition at line 146 of file NetMsgsGenPy.py.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.AugmentXmlDB().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintBriefComment | ( | self, | |
| fp, | |||
| brief | |||
| ) |
Print doxygen brief comment block. Parameters: fp - Opened output file pointer. brief - Brief comment.
Definition at line 795 of file NetMsgsGenPy.py.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.WriteFTDict(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.WriteMsgDefSet().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintMajorDivComment | ( | self, | |
| fp, | |||
| comment | |||
| ) |
Prints major file division comment block. Parameters: fp - Opened output file pointer. comment - Major division comment line.
Definition at line 761 of file NetMsgsGenPy.py.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenClass(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict(), NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDefSet(), and NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgIds().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintMinorDivComment | ( | self, | |
| fp, | |||
| comment | |||
| ) |
Prints minor file division comment block. Parameters: fp - Opened output file pointer. comment - Minor division comment line.
Definition at line 778 of file NetMsgsGenPy.py.
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintTopComment | ( | self, | |
| fp | |||
| ) |
Prints source file top comment block. Parameters: fp - Opened output file pointer.
Definition at line 721 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mPyBaseName, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, and NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml.
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenSource().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.WriteFTDict | ( | self, | |
| fp | |||
| ) |
Write field types and field type dictionary. Parameters: fp - Opened output file pointer.
Definition at line 573 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mFTDict, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintBriefComment(), and NetMsgs.NetMsgsGenC.NetMsgsGenC.PrettyPrintBriefComment().
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenFTDict().
| def NetMsgs.NetMsgsGenPy.NetMsgsGenPy.WriteMsgDefSet | ( | self, | |
| fp | |||
| ) |
Write message definitions and message definition set dictionary. Parameters: fp - Opened output file pointer.
Definition at line 594 of file NetMsgsGenPy.py.
References NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mMsgDefSet, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.mXml, NetMsgs.NetMsgsGenC.NetMsgsGenC.mXml, NetMsgs.NetMsgsGenPy.NetMsgsGenPy.PrettyPrintBriefComment(), and NetMsgs.NetMsgsGenC.NetMsgsGenC.PrettyPrintBriefComment().
Referenced by NetMsgs.NetMsgsGenPy.NetMsgsGenPy.GenMsgDefSet().