![]() ![]() """ _context = None _store = None _slave = None STORE_NAMES = def handle_save_start ( self ): """Handle save start.""" self. that persists the context as a json document. handle_save_end () # - # predefined state machine callbacks # - def handle_save_start ( self ): """Handle save start.""" def handle_store_start ( self, store ): """Handle store start.""" def handle_store_end ( self, store ): """Handle store end.""" def handle_slave_start ( self, slave ): """Handle slave start.""" def handle_slave_end ( self, slave ): """Handle slave end.""" def handle_save_end ( self ): """Handle save end.""" # - # Implementations of the data store savers # - # class JsonDatastoreSaver ( ModbusDatastoreSaver ): """An implementation of the modbus datastore saver. handle_store_values ( iter ( store )) # pylint: disable=no-member self. handle_slave_start ( slave_name ) for store_name, store in slave. handle_save_start () for slave_name, slave in self. file_handle : # pylint: disable=attribute-defined-outside-init self. """ with open ( # pylint: disable=unspecified-encoding self. which calls the various callbacks which the sub classes will implement. path = path or "modbus-context-dump" def save ( self ): """Save the context to file. :param context: The modbus server context :param path: The output path to save to """ self. """ def _init_ ( self, context, path = None ): """Initialize a new instance of the saver. In order to use it, just complete the necessary callbacks (SAX style) that your persistence format needs. that can be used to implement a persistence format for the modbus server context. At the moment, the supported output formats are: * csv * json * xml To implement your own, simply subclass ModbusDatastoreSaver and supply the needed callbacks for your given format: * handle_store_start(self, store) * handle_store_end(self, store) * handle_slave_start(self, slave) * handle_slave_end(self, slave) * handle_save_start(self) * handle_save_end(self) """ import json import as xml # nosec class ModbusDatastoreSaver : """An abstract base class. There use is very simple:: context = ntext saver = JsonDatastoreSaver(context) saver.save() These can then be re-opened by the parsers in the modbus_mapping module. that can be used to save a modbus server context to file for backup, checkpointing, or any other purpose. """These are a collection of helper methods. Asynchronous client extended calls example.Asynchronous Client basic calls example.Synchronous client extended calls example.Asynchronous Asyncio Modbus TLS Client Example. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |