Skip to content

Reading a tag value along with the PLC time #175

Answered by ottowayi
AlexRegev asked this question in Q&A
Discussion options

You must be logged in to vote

It's not part of the CIP protocol, but you can easily add the functionality using the get_plc_time method. There are many ways to do it, but here is a short example that adds the timestamp by subclass the LogixDriver and adds a read_with_timestamp method:

class MyLogixDriver(LogixDriver):

    def read_with_timestamp(self, *tags):
        plc_time = self.get_plc_time().value["string"]
        results = self.read(*tags)

        return [(*result, plc_time) for result in results]
with MyLogixDriver("192.168.1.236") as plc:
    tags = plc.read_with_timestamp("read_dint1", "read_sint1")

print(tags)

Output

[('read_dint1', 0, 'DINT', None, 'Wednesday, October 20, 2021 09:07:29PM'), ('read_si…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@AlexRegev
Comment options

@ottowayi
Comment options

Answer selected by AlexRegev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants