Home AMX User Forum NetLinx Studio

Update status on Panel online event

Hello all, I worked with AMX to get a simple include file that I use for AMX control of Vantage Infusion systems. This is a simple (less than 100 lines) piece of code, that issues commands to toggle a load based on the touchpanel button having the same # as the vantage VID (essentially button.input.channel). It also uses updates feedback based on LED status of the Vantage system. So, if a keypad/button is added to the vantage system, all that needs to be done is add the button on the touchpanel file with the matching channel # and it works perfectly.
This is working perfectly, but I want to take it to the next level. For the panels that reside in the system all the time, I have no complaints. The problem is that now i have implemented two iphone panels via TPcontrol. These are only connected to the system from time to time, and as such are never really tracking the feedback. Ie. when I open TPcontrol and connect, all my buttons are in the off state, until the load state changes again, so if there are lights currently on, I have no clue. I'd like to be able to somehow track this data in the master and then on a panel online event update that panel (or my panel array I created) with the CURRENT state of all the loads. Any thoughts on how to do this?
PROGRAM_NAME='VANTAGE_INFUSION'

Define_Device

dvVantageController=0:6:0
dvLIGHTMVP    =10002:15:0
dviPHONE1TP_LT	= 10006:15:0	//MR-IPHONE TOUCHPANEL
dviPHONE2TP_LT	= 10007:15:0	//Mrs-IPHONE TOUCHPANEL

DEFINE_VARIABLE

Volatile CHAR cVantageBuffer[100]
VOLATILE CHAR cVantageIP[15]='xxx.xxx.xxx.xxx'
VOLATILE LONG lVantagePort=3001

DEV dvlightingTP[]=
{
    dvLIGHTMVP,
    dviPHONE1TP_LT,
    dviPHONE2TP_LT
}


DEFINE_START

IP_CLIENT_OPEN(dvVantageController.Port,cVantageIP,lVantagePort,1)

CREATE_BUFFER dvVantageController,cVantageBuffer
DEFINE_FUNCTION fnVantageStringProcess(CHAR cStringToProcess[])
{
STACK_VAR INTEGER nLEDNum
STACK_VAR INTEGER nLEDSTATUS
IF(FIND_STRING(cStringToProcess,'S:LED ',1))//LED Feedback
    {
    REMOVE_STRING(cStringToProcess,'S:LED ',1)
    nLEDNum=ATOI(cStringToProcess)
    SEND_STRING 0,"'LED Number is',ITOA(nLEDNum)"
    REMOVE_STRING(cStringToProcess,ITOA(nLEDNum),1)
    nLEDStatus=ATOI(cStringToProcess)
    SEND_STRING 0,"'LED Number ',ITOA(nLEDNum),' LED Status is ',ITOA(nLEDStatus)"
    //REMOVE_STRING(cStringToProcess,ITOA(nLEDStatus),1)
    [dvLightingTP,nLEDNum]=nLEDStatus
     }
IF(FIND_STRING(cStringToProcess,'R:STATUS LED',1))//Tells us it received the fact that LED trackign is on
    {

    Send_String 0, 'LEDs Are Tracking Now'
    }
}
DEFINE_EVENT

BUTTON_EVENT [dvLightingTP,0]
{
Push:
    {
    SEND_STRING dvVantageController,"'BTNPRESS ',ITOA(BUTTON.INPUT.CHANNEL),$0D,$0A"
    }
RELEASE:
    {
     SEND_STRING dvVantageController,"'BTNRELEASE ',ITOA(BUTTON.INPUT.CHANNEL),$0D,$0A"
    }
}

DATA_EVENT[dvVantageController]
{
Online:
    {
    SEND_STRING 0,"'Vantage LED Tracking Online'"
       WAIT 400
	{
	//SEND_STRING dvVantageController, "'STATUS LED',$0D,$0A"//make it start feeding back
	}
    }
Offline:
    {
    SEND_STRING 0,"'Vantage LED Tracking Offline'"

    }
STRING:
    {
    Send_String 0, "'Vantage String - ',DATA.TEXT"
    While (FIND_STRING(cVantageBuffer,"$0D",1))
	{
	SEND_STRING 0, 'In The Vantage String Processing While loop'
	fnVantageStringProcess(REMOVE_STRING(cVantageBuffer,"$0D",1))
	}
    }
}


Comments

  • viningvining Posts: 4,368
    You need to create an array or preferably a structure to hold the values as they come in and update the TPs that are online or preferably "on page" (lighting page). Then in the online event you can run a loop and update the panel that came online by running th loop through this structure or array. Since the panel comining online doesn't neessarily mean they'll go to the lighting page I tend to update on a page by page basis so I update the main page when a panel comes online and update the pages when a TP goes to a specific page. Of course that requires tracking pages or having a button channel specific to opening a page and another channel specific to closing. If you're not geared up for that kind of FB control already just update everything that needs updating when they come online.
Sign In or Register to comment.