Home AMX User Forum AMXForums Archive Threads AMX Applications and Solutions

PCLinkExtra problem

Hello everybody,
I have a situation: one system will be controlled from AXD-CP4 touch panel and from PCLinkExtra based application (written using Delphi).
I use commands send_level and buttons with feedback=channel.
DEFINE_DEVICE

dvTP = 128:1:0
dvPC = 8001:1:0

DEFINE_PROGRAM

SEND_LEVEL dvTP,1,ACTIVE_MS_SOURCES
SEND_LEVEL dvPC,5,ACTIVE_MS_SOURCES

[dvTP,82] = AP_MUTE
[dvPC,39] = AP_MUTE

Let's have the situation:
ACTIVE_MS_SOURCES = 113
AP_MUTE = 1

When I disconnect/connect dvTP to the system, the dvTP shows the right status of level (113) and also of feedback channel 82 (ON) - there is no problem.

But when I disconnect/connect dvPC to the system, the dvPC shows the WRONG status of level (0) and also of feedback channel 82 (OFF) - in other words, this device doesn't get actual informations from the system after going online.

So, I checked out, if master is automatically sending refresh informations to the PCLinkExtra based application after ONLINE event - and I was surprised, that yes !!!

Line 7 :: Level Value To [8001:1:1] - Level 5 Value= 113 - 13:13:37
Line 8 :: Feedback:On [8001:1:1] - Channel 39 - 13:13:37
Line 9 :: Output Channel:On - From [8001:1:1] - Channel 39 - 13:13:37
Line 10 :: Output Channel Count [8001:1:1] - 1024 - 13:13:37
Line 11 :: Level Count [8001:1:1] - 32 - 13:13:37
Line 12 :: String Size [8001:1:1] 2000 byte(s) Type: 8 bit - 13:13:37
Line 13 :: Command Size [8001:1:1] 2000 byte(s) Type: 8 bit - 13:13:37

So, problem seems to be, that PCLinkExtra based application doesn't receive info immediately after going online - so I decided to write some short piece of "refresh code" with some delay:
DATA_EVENT[dvPC]
{
  ONLINE:  
 {
  WAIT 10 // wait 1s and then start sending
     SEND_STRING dvPC,"'LEVEL-5-',ITOA(ACTIVE_MS_SOURCES)"
  WAIT 12 // after 0.2s send next etc...
    IF ([AP_MUTE])
      SEND_STRING dvPC,"'CHANNEL-39-ON'"
   ELSE
      SEND_STRING dvPC,"'CHANNEL-39-OFF"
 }
}
// of course on the PC application side I have to read these strings and interpret.

But problem is, that sometimes I need to wait 1s after online event occurs and it's working, but sometimes I do not receive anything - then I make this time bigger - 5s - but again - for exam, when I was trying to connect from my PC application to 15 masters - then I lost my data from the refresh code also after 10s waiting!!!

So, does anybody have the same experience? Any idea, if problem should be on the PCLinkExtra.dll, or I have to write the whole code a different way?

Comments

  • NMarkRobertsNMarkRoberts Posts: 455
    Virtual devices don't see asserts if there is no change

    This reminds me of a similar problem I've experienced. I think it goes like this.

    If you communicate (eg) between modules via a virtual device and you assert a given value eg "channel on" when it is *already on*, the receiving module never sees that assert and (eg) never sends the value to the touchpanel that's just connected.

    The remedy is to send an inverted value then send the correct value - (!bValue) then (bValue), or 255-nLevelValue then nLevelValue. All my wrapper functions for sending values to touchpanels have an option to do this which is controlled by a global flag. On seeing a touchpanel come online, I set the flag, refresh all touchpanel state, wait 1 second and unset the flag.

    {Yet one more reason to wrap ALL low-level calls in define_functions of your own.}
  • rcervenanrcervenan Posts: 19
    Sorry, but I don't think this is a case
    This reminds me of a similar problem I've experienced. I think it goes like this.

    If you communicate (eg) between modules via a virtual device and you assert a given value eg "channel on" when it is *already on*, the receiving module never sees that assert and (eg) never sends the value to the touchpanel that's just connected.

    The remedy is to send an inverted value then send the correct value - (!bValue) then (bValue), or 255-nLevelValue then nLevelValue. All my wrapper functions for sending values to touchpanels have an option to do this which is controlled by a global flag. On seeing a touchpanel come online, I set the flag, refresh all touchpanel state, wait 1 second and unset the flag.

    {Yet one more reason to wrap ALL low-level calls in define_functions of your own.}
    Thank you for posting, but unfortunatelly I think this is not a case. Programming PCLinkExtra based application is working a little bit different way then a standard touch panel or AMX device. You do not have on PC side a standard AMX bargraphs, buttons etc. - on PC side I see everything coming from a master like incoming events (channel-on/off, levels changing, command and string events) and then I'm showing the decoded value on the windows based application : so in my windows app code I'm reading events - and then I evaluate what I received and after that I decide, how I will represent it - if channel goes on, I should for exam shut down PC (it means, my buttons and bargraphs are not connected automatically to channel-on/off and level events on ICSP layer, but I have to write a piece of code on PC side to connect them). So, problem, like you described, I can solve (and I did many times before) by sending strings (send_string), which I have to evaluate on the PC side:
         SEND_STRING dvPC,"'LEVEL-5-',ITOA(ACTIVE_MS_SOURCES)"
         SEND_STRING dvPC,"'CHANNEL-39-ON'"
    
    Problem is, that I don't receive on PC side neither channel-on/off event (sended automatically by master after online event) nor strings events (sended after some time by me - refresh code) - precisely I'm not able to find exact wait time for sending this refresh code, because sometime it works already with 1s delaying after online, sometime it does NOT work even after 10s waiting !
    So thanks for reply, any other idea?
  • AuserAuser Posts: 506
    Sorry, old post I know, but I think I know what's going on here. Working with PCLinkPlus, the behaviour of the master to devices going offline seems to be to forget level/channel values for that device (ie. they all become zero).

    I can't remember exactly what transpires when devices go offline, but the solution I used was to combine_levels and combine_channels the PCLink device levels and channels I was interested in with levels and channels on a virtual device. Thus they persist when the PCLink device goes offline and are initialised correctly when it next comes online.

    I think define_combine'ing the PCLink device with a virtual device would probably do the same thing for you, but in my case I wanted to see which device was generating events as opposed to seeing them all come from the virtual device.

    Edit: Oops, didn't read through your device notifications dump properly! I can only guess that in your case your application sometimes connects to the master before the event handlers for channel/level events generated by the PCLink instance have been created.
Sign In or Register to comment.