Results 1 to 6 of 6

Thread: Trouble with update of LABEL type control.

  1. #1
    Join Date
    May 2004
    Location
    France
    Posts
    250

    Default Trouble with update of LABEL type control.

    I have a trouble with the update of a control of the label type
    I created a plugin to read data from a Serial Device.
    The plugin works well.
    I created a control of type LABEL

    Click image for larger version. 

Name:	control view.png 
Views:	92 
Size:	4.9 KB 
ID:	6567

    In my .js file, I set
    Code:
    control.dtype = Promixis.Control.LABEL;
    This part of setup is not describe in the documentation. Because for control type, the documentation says :
    Code:
    Promixis.Control.DType.LABEL
    The numeric value of this control type sems to be 0

    Click image for larger version. 

Name:	treeview.png 
Views:	84 
Size:	6.4 KB 
ID:	6568
    When I check in the variable inspector, I read that the value type of my control is 3 ... (strange)

    Click image for larger version. 

Name:	actualtype.png 
Views:	87 
Size:	5.8 KB 
ID:	6569
    My trouble is that I can't change or update the value.
    I used the deviceManager.requestControlValueChange function to check the update of my control
    Code:
    deviceManager.requestControlValueChange(73, "50", "Teleinfo")
    

    For that, I updated the function onControlValueChangeRequest of my device and I set a code like this :
    Code:
    function onControlValueChangeRequest(self, control, value, sender)
        
         if not self.Teleinfo1 then
              return
         end
        control.ccontrol.value = value
        
    end

    The function is call with my new value but the value of the control is not updated.
    I can't set a value and the actual value of this control remains empty.
    Click image for larger version. 

Name:	valueempty.png 
Views:	92 
Size:	5.9 KB 
ID:	6570

    Is that the good way to use this function ?

    I used the dm.qml file to check too but the numeric value is empty too:
    Click image for larger version. 

Name:	dm.png 
Views:	104 
Size:	188.1 KB 
ID:	6571

    -------
    Another question is how to include the update of the control directly from my plugin code.
    I started from the PIO1 plugin source code.
    I read data from my serial device in the init.lua file.
    My ReadTeleinfo function parse the data from the serial device.
    Code:
    local connectionCallback = function(self, event, reason ,callback)
         if event == Promixis.Transport.IConnectionCallback.Status.CONNECTION_ESTABLISHED then
              print("Connection Established")
         
          --gir.triggerEvent("Teleinfo started on port" .. " " .. self.Comport, self.plugin.id, Promixis.Event.MOD_ON )
          gir.log(Promixis.Log.OK, self.name, "Teleinfo started on port" .. " " .. self.Comport)
        
          receiveData(self, function( data )
            --print(data)
            ReadTeleinfo(self, data)
              end)         
         
          if callback then
                callback(true)
            end
         
         end
    
    But I don't success in getting the control object to try to update the value of my label.
    How to do that ?
    Because the functions with deviceManager are not accessible within my lua plugin code.
    Thanks


  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Just got back from a grueling week installing 2 PEAC systems. I'll get to your questions this week.
    Ron
    No support through PM

  3. #3
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    I believe setting control.hardwareValue to the value you'd like will propagate the value into the DM system.

    Code:
    function onControlValueChangeRequest(self, control, value, sender)
        
         if not self.Teleinfo1 then
              return
         end
        control.ccontrol.hardwareValue = value
        
    end
    You can find an example in the PIO1 directory. The file device.lua around line 67 where the relay status and value is set.
    Ron
    No support through PM

  4. #4
    Join Date
    May 2004
    Location
    France
    Posts
    250

    Default

    Thanks Ron.
    For the onControlValueChangedRequest, your hints works. It's update the control.

    For the update of the plugin. I didn't find the answer for the moment. It's the serial device that get the value and ned to update the control. The update fonction are in the init.lua file so I don't have the control object to work on directly.
    I don't know how to work on the good lua object...

  5. #5
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Typically I like to keep the init.lua specific to the hardware and no knowledge of the device manager.

    I tend to use one of two methods of getting info out of init.lua.

    1: Using publisher.lua send events to the device manager interaction code. For example the globalcache plugin does this.
    2: Alternatively you could use callbacks, if you only expect changes to happen in response to your own code. This latter is how the PIO1 code works.
    Ron
    No support through PM

  6. #6
    Join Date
    May 2004
    Location
    France
    Posts
    250

    Default

    I am trying to understand how codes work and I found a
    Code:
    plugin.sendOutbound
    function and I didn't understand the goal of this method.

    Thanks
    Romain

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •