Hi Dave, Thank you for these ideas. Since I posted this the code has got longer as I have dived in and added more comments and docstrings to all the properties. Once I have finished commenting and documenting the functional code I will look at breaking it out in to separate files. I could probably do it BEFORE I finish the commenting but i'm on a bit of a role and if I get distracted I will probably never get back to it. Regards, David
On 18 May 2018 at 14:41, David O'Keeffe <david...@gmail.com> wrote: > Hey David, > > I've been working on something similar for the Sungrow SH5K inverter > talking through the Modbus protocol. From looking over your code briefly, > it's an almost 2000 line script, I can't easily make sense of what your > logic is. > > I'd take the long list of initializations out as a dictionary in another > py file and write an abstract function for code blocks like this. > > @property > def PowerApparent_S_Phase_1(self): > if (self._checkdatacurrency(self.MeterRealTimeData. > PowerApparent_S_Phase_1)): > return self.MeterRealTimeData.PowerApparent_S_Phase_1.Value > else: > self._GetMeterRealtimeData() > return self.MeterRealTimeData.PowerApparent_S_Phase_1.Value > @property > def PowerApparent_S_Phase_2(self): > if (self._checkdatacurrency(self.MeterRealTimeData. > PowerApparent_S_Phase_2)): > return self.MeterRealTimeData.PowerApparent_S_Phase_2.Value > else: > self._GetMeterRealtimeData() > return self.MeterRealTimeData.PowerApparent_S_Phase_2.Value > Cheers, > Dave > > > On Fri, May 18, 2018 at 2:05 PM, William ML Leslie < > william.leslie....@gmail.com> wrote: > >> On 18 May 2018 at 13:40, paul sorenson <new...@metrak.com> wrote: >> > My inverter came with a CD-ROM which would push a cloud somewhere but I >> > reckon it would be fun to crowd source really granular data. >> > >> >> The ability to push clouds is a great feature for a solar inverter to >> have. >> >> -- >> William Leslie >> >> Notice: >> Likely much of this email is, by the nature of copyright, covered >> under copyright law. You absolutely MAY reproduce any part of it in >> accordance with the copyright law of the nation you are reading this >> in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without >> prior contractual agreement. >> _______________________________________________ >> melbourne-pug mailing list >> melbourne-pug@python.org >> https://mail.python.org/mailman/listinfo/melbourne-pug >> > > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug@python.org > https://mail.python.org/mailman/listinfo/melbourne-pug > >
_______________________________________________ melbourne-pug mailing list melbourne-pug@python.org https://mail.python.org/mailman/listinfo/melbourne-pug