Attribute' value update

Hi all,

I have program in which I read register's value over Modbus.
In main thread I have method read_Reg defined like below:
def read_Reg(self, attr):
        self.info_stream("Command number = %d" % self.ord)
        # variable that is used for tracking how often this function is called
        self.ord += 1
        if (self.get_state() in [PyTango.DevState.STANDBY]):
            self.attr_Reg_read = self.mtc.read_holding_registers(2, 1, unit=1)
            self.info_stream("Data = %d" % self.attr_Reg_read.registers[0])
            attr.set_value(self.attr_Reg_read.registers[0])
        elif (self.get_state() in [PyTango.DevState.RUNNING]):
            self.info_stream("Data = %d" % self.Reg_Data)
            attr.set_value(self.Reg_Data)
In Standby mode, value of register is constant, while in Running state value is changing every 100ms. This is enabled by another thread beside main.This thread is started by executing command Change, and stopped by executing command Stop.
def t_Run_Reg(self):
        self.set_state(PyTango.DevState.RUNNING)
        self.t_mtc = ModbusTcpClient(host="10.1.1.138", port=502)
        while (self.t_mtc.connect() == False):
            pass
        try:
            # used for control when to start or stop thread
            while not self.t_LED_stop:
                 regN = (random.sample([4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768], 1)).pop()
                self.t_mtc.write_register(52, regN, unit=1)
                self.Reg_Data = regN
                time.sleep(self.speed / 1000.0)
        finally:
            self.t_mtc.close()
At start of a thread I'm establishing connection, and when it is established, I choose one random number and write it to the PLC' register.

When I start program, register change its value at speed of 100ms on the PLC's side, but its value isn't displayed in AtkPanel. But when I click on three dots on the right, current value of register is showed.
In the first picture is the moment before clicking three dots
.
In the next picture is the moment after clicking three dots.

From this you can see that function read_Reg is called only by clicking on three dots (I dont know If that means that I want to refresh values, but my refresh period is already set to 1000ms).
What is more confusing, from Log Viewer you can see that command is called twice in a row.

My question is next, why function read_Reg isn't called every 1000ms, which is my refreshing period?
Again, second thread is working fine changing register's value, and when I click on three dots, read value is correct.
I hope I was clear enough so someone can help me.

Best regards,
Dusan

Edited 7 years ago
Hi,

In atkpanel, I encourage you to have a look at View menu –> Error History, to visualize the error history associated with Diode attribute.
You could also have a look at View Menu –> "Diagnostic…" to see whether atkpanel is using events to get updates from the Diode attribute.

This might be an event re-connection issue because I guess you are restarting very often your device servers (should not be a problem in theory but well).
Please note that you need to wait a least 10 seconds after the device server restart to be sure the reconnection had a chance to happen.
If you restart another atkpanel on the same device from another jvm (So if you started it from jive, start another atkpanel from the command line or from a new jive), the new atkpanel will probably behave well, unless you have a problem with your network configuration.

I take this opportunity to warn the Tango community that there are event reconnection issues if you just rename a server instance name.
When you rename a server instance name, this will actually rename the admin device associated to your device server. The reconnection mechanism is sending commands to the admin device to re-subscribe to events.
This case is currently not well handled by Tango which will continue to try to contact the old admin device.
So, until this is fixed, if you rename a device server instance, please restart all the clients which were subscribed to events from the previous instance of the device server.

Kind regards,
Reynald

Kind regards,

Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new.
 
Register or login to create to post a reply.