Model Railroad System  2.2.1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
lcc::ConfigurationEditor Class Reference

Generate OpenLCB Memory Configuration Window. More...

Public Member Functions

 ConfigurationEditor (name,...)
 Constructor: create the configuration editor. More...
 

Private Member Functions

 putdebug (message)
 Print message using debug output, if any. More...
 
 _processXMLnode (n, frame, space, address_var, prefix="")
 Process one node in the XML tree. More...
 
 _printexport (node, frame, name)
 Print or export a segment or group. More...
 
 _printexport_pdf (node, frame, name, outfile)
 Export a segment or group to a printable PDF file. More...
 
 _printexport_xml (node, frame, name, outfile)
 Export a segment or group to an XML file. More...
 
 _printexport_csv (node, frame, name, outfile)
 Export a segment or group to a CSV file (can be imported into Excel). More...
 
 _printexport_txt (node, frame, name, outfile)
 Export a segment or group to a text file. More...
 
 _close ()
 Close the window. More...
 
 _datagramhandler (command, sourcenid,...)
 Datagram handler. More...
 
 _readmemory (space, address, length, status_var)
 Read memory from a space. More...
 
 _writememory (space, address, databuffer)
 Write to configuration memory. More...
 
 _intComboRead (widget, space, address, size)
 Read an integer value and map it to a ComboBox widget. More...
 
 _intComboWrite (widget, space, address, size, min, max)
 Write an integer value maped from a ComboBox widget. More...
 
 _intSpinRead (widget, space, address, size)
 Read an integer value and stash it in a SpinBox widget. More...
 
 _intSpinWrite (widget, space, address, size, min, max)
 Write an integer value maped from a SpinBox widget. More...
 
 _stringComboRead (widget, space, address, size)
 Read a string value and map it to a ComboBox widget. More...
 
 _stringComboWrite (widget, space, address, size)
 Write a string value maped from a ComboBox widget. More...
 
 _stringEntryRead (widget, space, address, size)
 Read a string value and stash it in an Entry widget. More...
 
 _stringEntryWrite (widget, space, address, size)
 Write a string value from an Entry widget. More...
 
 _eventidComboRead (widget, space, address, size)
 Read an event id value and map it to a ComboBox widget. More...
 
 _eventidComboWrite (widget, space, address, size)
 Write an event id value maped from a ComboBox widget. More...
 
 _eventidEntryRead (widget, space, address, size)
 Read an event id value and stash it in an Entry widget as an event id string. More...
 
 _eventidEntryWrite (widget, space, address, size)
 Write an event id value from an Entry widget. More...
 
 _readall (space)
 Read all parameters stored in a specified space. More...
 

Static Private Member Functions

static _printexport_pdf_frame (n, indent, pdfobj, frame, curyVar, curpageVar, pageheader)
 Export a node frame to a PDF file. More...
 
static _printexport_pdf_vframe (n, indent, pdfobj, frame, curyVar, curpageVar, pageheader)
 Export a node scaler value frame to a PDF file. More...
 
static _printexport_pdf_newpage (pdfobj, pageheader, pageno)
 Print a new PDF page. More...
 
static _printexport_xml_frame (n, frame)
 Export a node frame as an XML tree. More...
 
static _printexport_xml_vframe (n, frame)
 Export a scaler node's value frame as an XML tree. More...
 
static _printexport_csv_frame (n, matrix, frame)
 Add a node's GUI frame values to a matrix (to be exported as a CSV file). More...
 
static _printexport_csv_vframe (n, matrix, frame)
 Add a scaler node's GUI value frame values to a matrix (to be exported as a CSV file). More...
 
static _printexport_csv_framesAcross (n, tabnb, tabs, matrix)
 Add a replicated group to a matrix as a single row. More...
 
static _printexport_csv_frameAcross (n, rowVar, frame)
 Add a group to a matrix as elements to a single row. More...
 
static _printexport_csv_vframeAcross (n, rowVar, frame)
 Add a scaler node's value frame to a matrix as elements to a single row. More...
 
static _printexport_txt_frame (n, indent, outfp, frame)
 Export a segment or group frame to a text file. More...
 
static _printexport_txt_vframe (n, indent, outfp, frame)
 Export a node scaler value frame to a text file. More...
 

Private Attributes

 main
 Main Frame. More...
 
 scroll
 Scrolled Window. More...
 
 editframe
 Scrollable Frame. More...
 
 buttons
 Button box. More...
 
 cdi
 CDI XML Object. More...
 
 _ioComplete
 I/O Completion Flag. More...
 
 statusline
 Status variable. More...
 
 _readall
 Holds all of the Read buttons for each segment. More...
 
 _segmentnumber
 Segement number, used to insure unique widget names. More...
 
 _groupnumber
 Group number, used to insure unique widget names. More...
 
 _intnumber
 Integer number, used to insure unique widget names. More...
 
 _stringnumber
 String number, used to insure unique widget names. More...
 
 _eventidnumber
 Eventid number, used to insure unique widget names. More...
 
 _mkbuttons
 Flag for Make Sensor / Make Turnout etc. More...
 
 olddatagramhandler
 Variable holding the old Datagram handler. More...
 
 datagrambuffer
 Datagram buffer. More...
 
 _datagramrejecterror
 Datagram reject error flag. More...
 
 writeReplyCheck
 Datagram write trply check flag. More...
 

Static Private Attributes

static _menu
 Generic menu. More...
 
static idheaders
 Locale versions of the identification headers. More...
 
static printexportfiletypes
 Print and Export file types. More...
 

Detailed Description

Generate OpenLCB Memory Configuration Window.

Create a toplevel to configure a node's Memory using that node's (parsed) CDI. This GUI uses tabbed notebook widgets for segments and replicated groups to reduce the amount of scrolling (and because a ginormous scrollable frame dies with a X11 Pixmap allocation error).

Parameters
Options
  • -cdi The parsed CDI xml. Required and there is no default.
  • -nid The Node ID of the node to be configured. Required and there is no default.
  • -transport The transport object. Needs to implement SendDatagram, DatagramReceivedOK, and DatagramRejected methods and have an -datagramhandler option.
  • -displayonly A flag indicating that the CDI is just to be displayed. The default is false.
  • -offlineedit A flag indicating that the this is an offline editor. The default is false.
  • -loadfile The backup config filename to load from. Only checked if -offlineedit is true. Default is an empty string.
  • -debugprint A function to handle debug output.
  • -class Delegated to the toplevel.
  • -menu Delegated to the toplevel
  • -height Delegated to the ScrollableFrame
  • -areaheight Delegated to the ScrollableFrame
  • -width Delegated to the ScrollableFrame
  • -areawidth Delegated to the ScrollableFrame

Constructor & Destructor Documentation

◆ ConfigurationEditor()

lcc::ConfigurationEditor::ConfigurationEditor ( name  ,
  ... 
)

Constructor: create the configuration editor.

Construct a memory configuration window to edit the configuration memory of an OpenLCB node. The window is created from the toplevel up.

Parameters
nameWidget path.
...Options:
  • -cdi The parsed CDI xml. Required and there is no default.
  • -nid The Node ID of the node to be configured. Required and there is no default.
  • -transport The transport object. Needs to implement SendDatagram, DatagramReceivedOK, and DatagramRejected methods and have an -datagramhandler option.
  • -displayonly A flag indicating that the CDI is just to be displayed. The default is false.
  • -offlineedit A flag indicating that the this is an offline editor. The default is false.
  • -loadfile The backup config filename to load from. Only checked if -offlineedit is true. Default is an empty string.
  • -debugprint A function to handle debug output.
  • -class Delegated to the toplevel.
  • -menu Delegated to the toplevel
  • -height Delegated to the ScrollableFrame
  • -areaheight Delegated to the ScrollableFrame
  • -width Delegated to the ScrollableFrame
  • -areawidth Delegated to the ScrollableFrame

Member Function Documentation

◆ _close()

lcc::ConfigurationEditor::_close ( )
private

Close the window.

The window is withdrawn.

◆ _datagramhandler()

lcc::ConfigurationEditor::_datagramhandler ( command  ,
sourcenid  ,
  ... 
)
private

Datagram handler.

Parameters
commandType of Datagram handling.
sourcenidSource NID of the datagram.
...The datagram data stream.

◆ _eventidComboRead()

lcc::ConfigurationEditor::_eventidComboRead ( widget  ,
space  ,
address  ,
size   
)
private

Read an event id value and map it to a ComboBox widget.

Parameters
widgetA ttk::combobox widget to update. This is also used to map to the value map.
spaceThe space to read from.
addressThe address of the event id.
sizeThe size of the event id (should always be 8).

◆ _eventidComboWrite()

lcc::ConfigurationEditor::_eventidComboWrite ( widget  ,
space  ,
address  ,
size   
)
private

Write an event id value maped from a ComboBox widget.

Parameters
widgetA ttk::combobox widget to get the value from. This is also used to map to the value map.
spaceThe space to read from.
addressThe address of the event id.
sizeThe size of the event id (should always be 8).

◆ _eventidEntryRead()

lcc::ConfigurationEditor::_eventidEntryRead ( widget  ,
space  ,
address  ,
size   
)
private

Read an event id value and stash it in an Entry widget as an event id string.

Parameters
widgetA ttk::entry widget to update.
spaceThe space to read from.
addressThe address of the event id.
sizeThe size of the event id (should always be 8).

◆ _eventidEntryWrite()

lcc::ConfigurationEditor::_eventidEntryWrite ( widget  ,
space  ,
address  ,
size   
)
private

Write an event id value from an Entry widget.

Parameters
widgetA ttk::entry widget to get the value from.
spaceThe space to read from.
addressThe address of the event id.
sizeThe size of the event id (should always be 8).

◆ _intComboRead()

lcc::ConfigurationEditor::_intComboRead ( widget  ,
space  ,
address  ,
size   
)
private

Read an integer value and map it to a ComboBox widget.

Parameters
widgetA ttk::combobox widget to update. This is also used to map to the value map.
spaceThe space to read from.
addressThe address of the integer.
sizeThe size of the integer.

◆ _intComboWrite()

lcc::ConfigurationEditor::_intComboWrite ( widget  ,
space  ,
address  ,
size  ,
min  ,
max   
)
private

Write an integer value maped from a ComboBox widget.

Parameters
widgetA ttk::combobox widget to get the value from. This is also used to map to the value map.
spaceThe space to read from.
addressThe address of the integer.
sizeThe size of the integer.
minThe minimum allowed value of the integer.
maxThe maximum allowed value of the integer.

◆ _intSpinRead()

lcc::ConfigurationEditor::_intSpinRead ( widget  ,
space  ,
address  ,
size   
)
private

Read an integer value and stash it in a SpinBox widget.

Parameters
widgetA spinbox widget to update.
spaceThe space to read from.
addressThe address of the integer.
sizeThe size of the integer.

◆ _intSpinWrite()

lcc::ConfigurationEditor::_intSpinWrite ( widget  ,
space  ,
address  ,
size  ,
min  ,
max   
)
private

Write an integer value maped from a SpinBox widget.

Parameters
widgetA spinbox widget to get the value from.
spaceThe space to read from.
addressThe address of the integer.
sizeThe size of the integer.
minThe minimum allowed value of the integer.
maxThe maximum allowed value of the integer.

◆ _printexport()

lcc::ConfigurationEditor::_printexport ( node  ,
frame  ,
name   
)
private

Print or export a segment or group.

The current contents of the specified segment or group GUI frame are exported to a data file for use in another program or printed.

Parameters
nodeThe XML node in the CDI for the segment or group to export or print.
frameThe GUI frame containing the values to be exported or printed.
nameThe name of the segment or group to be exported or printed.

◆ _printexport_csv()

lcc::ConfigurationEditor::_printexport_csv ( node  ,
frame  ,
name  ,
outfile   
)
private

Export a segment or group to a CSV file (can be imported into Excel).

Parameters
nodeThe XML node in the CDI for the segment or group to export or print.
frameThe GUI frame containing the values to be exported or printed.
nameThe name of the segment or group to be exported or printed.
outfileThe file to export to.

◆ _printexport_csv_frame()

static lcc::ConfigurationEditor::_printexport_csv_frame ( ,
matrix  ,
frame   
)
staticprivate

Add a node's GUI frame values to a matrix (to be exported as a CSV file).

Parameters
nThe node in the CDI XML tree.
matrixThe matrix to populate.
frameThe GUI frame to extract values from.

◆ _printexport_csv_frameAcross()

static lcc::ConfigurationEditor::_printexport_csv_frameAcross ( ,
rowVar  ,
frame   
)
staticprivate

Add a group to a matrix as elements to a single row.

Parameters
nThe node in the CDI XML tree.
rowVarThe name of the variable containing the row to add to.
frameThe GUI frame.

◆ _printexport_csv_framesAcross()

static lcc::ConfigurationEditor::_printexport_csv_framesAcross ( ,
tabnb  ,
tabs  ,
matrix   
)
staticprivate

Add a replicated group to a matrix as a single row.

Parameters
nThe node in the CDI XML tree.
tabnbTabbed notebook containing the replicated group.
tabsThe tabs in the tabbed notebook (the replications).
matrixThe matrix to populate.

◆ _printexport_csv_vframe()

static lcc::ConfigurationEditor::_printexport_csv_vframe ( ,
matrix  ,
frame   
)
staticprivate

Add a scaler node's GUI value frame values to a matrix (to be exported as a CSV file).

Parameters
nThe node in the CDI XML tree.
matrixThe matrix to populate
frameThe GUI frame to extract values from.

◆ _printexport_csv_vframeAcross()

static lcc::ConfigurationEditor::_printexport_csv_vframeAcross ( ,
rowVar  ,
frame   
)
staticprivate

Add a scaler node's value frame to a matrix as elements to a single row.

Parameters
nThe node in the CDI XML tree.
rowVarThe name of the variable containing the row to add to.
frameThe GUI frame.

◆ _printexport_pdf()

lcc::ConfigurationEditor::_printexport_pdf ( node  ,
frame  ,
name  ,
outfile   
)
private

Export a segment or group to a printable PDF file.

Parameters
nodeThe XML node in the CDI for the segment or group to export or print.
frameThe GUI frame containing the values to be exported or printed.
nameThe name of the segment or group to be exported or printed.
outfileThe file to export to.

◆ _printexport_pdf_frame()

static lcc::ConfigurationEditor::_printexport_pdf_frame ( ,
indent  ,
pdfobj  ,
frame  ,
curyVar  ,
curpageVar  ,
pageheader   
)
staticprivate

Export a node frame to a PDF file.

Parameters
nThe node.
indentThe indentation string.
pdfobjThe PDF file object.
frameThe GUI frame.
curyVarThe name of the variable containing the current y location.
curpageVarThe name of the variable containing the current page number.
pageheaderThe running page header text.

◆ _printexport_pdf_newpage()

static lcc::ConfigurationEditor::_printexport_pdf_newpage ( pdfobj  ,
pageheader  ,
pageno   
)
staticprivate

Print a new PDF page.

Parameters
pdfobjThe PDF file object
pageheaderThe running page header text.
pagenoThe new page's number.
Returns
The fresh current y value.

◆ _printexport_pdf_vframe()

static lcc::ConfigurationEditor::_printexport_pdf_vframe ( ,
indent  ,
pdfobj  ,
frame  ,
curyVar  ,
curpageVar  ,
pageheader   
)
staticprivate

Export a node scaler value frame to a PDF file.

Parameters
nThe node.
indentThe indentation string.
pdfobjThe PDF file object.
frameThe GUI frame.
curyVarThe name of the variable containing the current y location.
curpageVarThe name of the variable containing the current page number.
pageheaderThe running page header text.

◆ _printexport_txt()

lcc::ConfigurationEditor::_printexport_txt ( node  ,
frame  ,
name  ,
outfile   
)
private

Export a segment or group to a text file.

Parameters
nodeThe XML node in the CDI for the segment or group to export or print.
frameThe GUI frame containing the values to be exported or printed.
nameThe name of the segment or group to be exported or printed.
outfileThe file to export to.

◆ _printexport_txt_frame()

static lcc::ConfigurationEditor::_printexport_txt_frame ( ,
indent  ,
outfp  ,
frame   
)
staticprivate

Export a segment or group frame to a text file.

Parameters
nThe node.
indentThe indentation string.
outfpThe output file channel.
frameThe GUI frame.

◆ _printexport_txt_vframe()

static lcc::ConfigurationEditor::_printexport_txt_vframe ( ,
indent  ,
outfp  ,
frame   
)
staticprivate

Export a node scaler value frame to a text file.

Parameters
nThe node.
indentThe indentation string.
outfpThe output channel.
frameThe GUI frame.

◆ _printexport_xml()

lcc::ConfigurationEditor::_printexport_xml ( node  ,
frame  ,
name  ,
outfile   
)
private

Export a segment or group to an XML file.

Parameters
nodeThe XML node in the CDI for the segment or group to export or print.
frameThe GUI frame containing the values to be exported or printed.
nameThe name of the segment or group to be exported or printed.
outfileThe file to export to.

◆ _printexport_xml_frame()

static lcc::ConfigurationEditor::_printexport_xml_frame ( ,
frame   
)
staticprivate

Export a node frame as an XML tree.

Parameters
nThe XML node in the CDI.
frameThe GUI frame for the node in the CDI.
Returns
An XML tree of the contents of the GUI frame.

◆ _printexport_xml_vframe()

static lcc::ConfigurationEditor::_printexport_xml_vframe ( ,
frame   
)
staticprivate

Export a scaler node's value frame as an XML tree.

Parameters
nThe XML node in the CDI.
frameThe GUI frame for the node in the CDI.
Returns
An XML tree of the contents of the GUI frame.

◆ _processXMLnode()

lcc::ConfigurationEditor::_processXMLnode ( ,
frame  ,
space  ,
address_var  ,
prefix  = "" 
)
private

Process one node in the XML tree.

Process a single node in the XML tree. Will recurse to process Children nodes.

Ttk::labelframes are used for variables with names. Ttk::notebooks, except segments and groups. A ttk::labelframe is also used for the information block.

Parameters
nThe node.
frameThe parent frame.
spaceThe current space.
address_varThe name of the address variable.

◆ _readall()

lcc::ConfigurationEditor::_readall ( space  )
private

Read all parameters stored in a specified space.

Reads each parameter one at a time by invoking the parameter's Read button.

Parameters
spaceThe parameter space to read from.

◆ _readmemory()

lcc::ConfigurationEditor::_readmemory ( space  ,
address  ,
length  ,
status_var   
)
private

Read memory from a space.

Parameters
spaceThe space to read from.
addressThe start address to read.
lengthNumber of bytes to read.
status_varThe name of a variable to receive the status code.
Returns
The data read (if successful).

◆ _stringComboRead()

lcc::ConfigurationEditor::_stringComboRead ( widget  ,
space  ,
address  ,
size   
)
private

Read a string value and map it to a ComboBox widget.

Parameters
widgetA ttk::combobox widget to update. This is also used to map to the value map.
spaceThe space to read from.
addressThe address of the string.
sizeThe size of the string.

◆ _stringComboWrite()

lcc::ConfigurationEditor::_stringComboWrite ( widget  ,
space  ,
address  ,
size   
)
private

Write a string value maped from a ComboBox widget.

Parameters
widgetA ttk::combobox widget to get the value from. This is also used to map to the value map.
spaceThe space to read from.
addressThe address of the string.
sizeThe size of the string.

◆ _stringEntryRead()

lcc::ConfigurationEditor::_stringEntryRead ( widget  ,
space  ,
address  ,
size   
)
private

Read a string value and stash it in an Entry widget.

Parameters
widgetA ttk::entry widget to update.
spaceThe space to read from.
addressThe address of the string.
sizeThe size of the string.

◆ _stringEntryWrite()

lcc::ConfigurationEditor::_stringEntryWrite ( widget  ,
space  ,
address  ,
size   
)
private

Write a string value from an Entry widget.

Parameters
widgetA ttk::entry widget to get the value from.
spaceThe space to read from.
addressThe address of the string.
sizeThe size of the string.

◆ _writememory()

lcc::ConfigurationEditor::_writememory ( space  ,
address  ,
databuffer   
)
private

Write to configuration memory.

Parameters
spaceThe space to write to.
addressThe address to write to.
databufferThe data to write.
Returns
The write status.

◆ putdebug()

lcc::ConfigurationEditor::putdebug ( message  )
private

Print message using debug output, if any.

Parameters
messageThe message to print.

Member Data Documentation

◆ _datagramrejecterror

lcc::ConfigurationEditor::_datagramrejecterror
private

Datagram reject error flag.

◆ _eventidnumber

lcc::ConfigurationEditor::_eventidnumber
private

Eventid number, used to insure unique widget names.

◆ _groupnumber

lcc::ConfigurationEditor::_groupnumber
private

Group number, used to insure unique widget names.

◆ _intnumber

lcc::ConfigurationEditor::_intnumber
private

Integer number, used to insure unique widget names.

◆ _ioComplete

lcc::ConfigurationEditor::_ioComplete
private

I/O Completion Flag.

◆ _menu

lcc::ConfigurationEditor::_menu
staticprivate

Generic menu.

◆ _mkbuttons

lcc::ConfigurationEditor::_mkbuttons
private

Flag for Make Sensor / Make Turnout etc.

buttons

◆ _readall

lcc::ConfigurationEditor::_readall
private

Holds all of the Read buttons for each segment.

This allows for Reading all of the variables in a segment.

◆ _segmentnumber

lcc::ConfigurationEditor::_segmentnumber
private

Segement number, used to insure unique widget names.

◆ _stringnumber

lcc::ConfigurationEditor::_stringnumber
private

String number, used to insure unique widget names.

◆ buttons

lcc::ConfigurationEditor::buttons
private

Button box.

◆ cdi

lcc::ConfigurationEditor::cdi
private

CDI XML Object.

◆ datagrambuffer

lcc::ConfigurationEditor::datagrambuffer
private

Datagram buffer.

◆ editframe

lcc::ConfigurationEditor::editframe
private

Scrollable Frame.

◆ idheaders

lcc::ConfigurationEditor::idheaders
staticprivate

Locale versions of the identification headers.

◆ main

lcc::ConfigurationEditor::main
private

Main Frame.

◆ olddatagramhandler

lcc::ConfigurationEditor::olddatagramhandler
private

Variable holding the old Datagram handler.

◆ printexportfiletypes

lcc::ConfigurationEditor::printexportfiletypes
staticprivate

Print and Export file types.

◆ scroll

lcc::ConfigurationEditor::scroll
private

Scrolled Window.

◆ statusline

lcc::ConfigurationEditor::statusline
private

Status variable.

◆ writeReplyCheck

lcc::ConfigurationEditor::writeReplyCheck
private

Datagram write trply check flag.