[Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)
prilisauer at googlemail.com
prilisauer at googlemail.com
Sat Dec 22 13:10:39 EST 2012
Am Samstag, 22. Dezember 2012 18:26:43 UTC+1 schrieb Alexander Blinne:
> Am 22.12.2012 13:45, schrieb:
>
> > Ps.: The Socket, the DB has to be kept allways open, because of it's Server functionality, A lot of Sensors, Timers, User interaction, must recived , Calculated, etc so a reaction must be send in about 16~100 ms, different modules opens and closes Sockets or files, could result in a dead situation.
>
> >
>
> >
>
> > Or do i didn't see any Tree's in the Wood?
>
>
>
> I would strongly recommend an object oriented view:
>
>
>
> Suppose Datastore.py contains a Class Datastore. You can instantiate
>
> that class once in the beginning of your main file and the resulting
>
> object has methods to store and retrieve data in/from the store.
>
>
>
> ModbusClient.py contains a Class Modbus. This also can be instantiated
>
> just once which opens a TCP connection to be used many times and you can
>
> hand over a reference to the Instance of Datastore you created earlier,
>
> so it can speak with the Datastore. The object has methods to do the
>
> things you want it to do.
>
>
>
> The Same for DaliBusClient.
>
>
>
> Now your main.py could look something linke
>
>
>
> from Datastore import Datastore
>
> from ModbusClient import Modbus
>
> from DaliBusClient import DaliBus
>
>
>
> def main():
>
> datastore = Datastore(...)
>
> modbus = Modbus(..., datastore)
>
> dalibus = DaliBus(..., datastore)
>
>
>
> modbus.read_data_and_save_to_store()
>
> dalibus.read_data_and_save_to_store()
>
>
>
> if __name__=="__main__":
>
> main()
Yes,
My Project is allready > 1000 lines and even more,..
I have started writing it, each module after another ...
I've got allready a lot of experience in other programming languages ( also I
have worked as a programmer)
But the question is, could communicate a DaliModul, Modbus,.. Etc with the backend db.
It's for me a view of top side down, but how could the midlevel comunicate to each oter... "not hirachical"
More information about the Python-list
mailing list