Reactive output register simulation
In real cases, when input registers change in value, some output registers would also change in value. For example, in an electric fan unit, an input register for power goes up, an output register for rotations per minute will also go up. Ofcourse the relationship of those two values isn't always linear. We actually need this feature and perhaps attach other kinds of formulas f(x) = y (perhaps via config) to simulate relationships between registers and also reaction times.
This is a very important feature to us. We'd like to know if this can be completed soon, otherwise, we'd like to ask for some direction perhaps which files and lines to check to implement this
@wongjasont I will take a look in to this. This is a very good feature to have but unfortunately I am finding it hard to work on these enhancements due to time constraint. There is no definite timeline. If you would like to take it up on your own, you are most welcome. You can have a look in to following methods
Note: The code needs a lot of refactor as it has a lot of UI related stuff (from the UI version)
A question; I've checked those functions you pointed out, added some "prints" (also tried printing via logger if print was disabled) just to see how they execute with the simulator but unfortunately I don't see them being executed.
I hope you could shed some light on how I could do this enhancement. I'm happy to work on this myself and perhaps help you out with this project by sharing my changes.
Note: Just learned PYTHON 2 days ago. I'm actually a JavaScript Developer.
@wongjasont apologies for the delayed response, I am glad that you want to contribute. To activate the simulation this method needs to be invoked. The method is still in it's GUI form (that is depends on the state of the button), you can change the argument to simple boolean (True -> Start Simulation and False -> Stop simulation). You will have to pass that info from the config file or from command line argument. (IT would require some code change and I am not sure of the complexity it involves) I would see if I can give some thing over the weekend. Thanks
@dhoomakethu
When setting simulating to true. I assume that runs the simulation similar to GUI, I was hoping for some prints to show somehow? Or is it not running?
Also, when I've tried executing start_stop_simulation as well, what happens is this error 'ModbusServer' object has no attribute 'data_model_coil', seems that data_model_coil is not yet initialised.
def _simulate(self): self.data_model_coil.start_stop_simulation(self.simulating) self.data_model_discrete_inputs.start_stop_simulation(self.simulating) self.data_model_input_registers.start_stop_simulation(self.simulating) self.data_model_holding_registers.start_stop_simulation( self.simulating)
Is there any part of the code where I can access the register data as if modifying them? It will be really helpful if you could point me in that direction. Thanks!
As I checked in main.py, these four data models for the different register types
self.data_model_coil self.data_model_discrete_inputs self.data_model_input_registers self.data_model_holding_registers
Were never initialized thus simulating seems impossible. That is why I asked in my last comment how to modify the models from the running servers