[Tutor] Hello! Questions

Marco Soldavini magyar1886 at gmail.com
Fri Feb 19 14:41:31 EST 2016


On Fri, Feb 19, 2016 at 3:32 PM, Peter Otten <__peter__ at web.de> wrote:

>
>
> Also, after reading http://openopc.sourceforge.net/api.html I wonder if it
> wouldn't be better to go with the timestamp provided by the server
>
>                   bool1.append(opc.read(".watchdog"))
>

yes but my next step is to load some of this data up to SQL and the
timestamp provided by the opc was difficult to manage into a TIME field. I
manage to insert the appended data instead with the timestamp generated
with my code.

I'll work more on that to see if it is possible to get the original
timestamp. I don't require high precision just something around the second
is ok.


>
> With a slight modification of Alan's suggestion you could write to a list
> of
> dicts instead of a dict of lists like so:
>
> # outside the loop
> WANTED = [".watchdog", ".analog1", ".analog2]
> data = []
>
> # in the loop:
>                  data.append({r[0]:r[1:] for r in opc.read(WANTED)})
>
>
>
Thanks for the helpful hints. I have a ton of questions yet to come!

Marco


More information about the Tutor mailing list