Home AMX User Forum AMX General Discussion

Resending level events on touchpanel reboot?

I'm sure I've done this before, but it's been a while, so here goes:

I have a loop that sends multiple level events to my touchpanel each time a change is sent to my autopatch switcher:
DATA_EVENT[AUTOPATCH]
{
    ONLINE:
    {
	SEND_COMMAND AUTOPATCH, "'SET BAUD 9600,N,8,1'"
    }
    STRING:
    {
	local_var char APResponse [50]
	local_var integer APSource
	local_var char APRooms [15]  //15 possible rooms
	local_var char dump[20]
	local_var integer input [10]
	local_var integer i
	APResponse = data.text
	IF(FIND_STRING(APResponse,'T',1))  //CL1I5O1 2 3T
	{
	    REMOVE_STRING(APResponse,'I',1) //deletes CL1I
	    //leaves APResponse with O1 2 3T
	    APSource = ATOI(LEFT_STRING(APResponse,1))  //copied the I5.
	    //APSource converted the I5 into just 5.
	    //APResponse now needs the outputs put into an array.
	    dump = REMOVE_STRING(APResponse,'O',1)  //takes the O out.
	    //this leaves 1 2 3T as the remaining string, APResponse.
	    APResponse = LEFT_STRING(APResponse,LENGTH_STRING(APResponse)-1) //removes T
	    APResponse = "APResponse,' '" //adds a space at the end
	    //got rid of the T, leaves just the #s
	    FOR(i=1;i<=9;i++)
	    {
		input[i] = ATOI(REMOVE_STRING(APResponse,' ',1))
		CurrentSource[input[i]] = APSource
		//SEND_COMMAND dvTP1, "'^TXT-',itoa(i),',',itoa(CurrentSource[i])"
		SEND_LEVEL dvTP1,i,CurrentSource[i]
		
		
	    }
	    
	    
	}
	
    }
}
At this point, whenever my touchpanel reboots, the level_event changes are lost. I understand that they all get set back to nothing on a reboot. How can I re-send the loop on reboot, without a command being sent to the switcher? I was thinking that perhaps I needed to set up an array to retain the info pulled from the string event, and then call it in the online event for the panel. Am I on the right track here?

Comments

  • viningvining Posts: 4,368
    Anytime a panel reboots or the master reboots I always send my Tp that rebooted or all TPs if the master rebooted back to the TPs main page. I do this in the TP port 1 data_event online handler. So I don't need to resend values to the various device pages when they return online. I only need to make sure my main page is fresh. If the user chooses to go to a page then when they return to a device page I'll refresh since as a general rule of thumb the device pages aren't being refresh when they are not on that device page.

    More to your point, I alway store values to refresh when I go "on a page" but if I'm not "on a page" I simply store values and if I'm "on page" I store for other TPs that might not be on page and I also directly update the current page. So if you store your values you can easily refresh for what ever method you choose to manage your feedback and it save you the need to re-poll the devices to refresh a TP that was rebooted.
  • PhreaKPhreaK Posts: 966
    I'd recommend seperating out your interface code from the system logic and state tracking. In your autopatch comms processing rather then directly updating the UI parse everything and update a structure/array with the relevant values then call a UI update function (which if you want to be really neat, takes the all the data it will need as an argument). That way when your TP comes online you can call the same function and everything will play nice.
  • vegastechvegastech Posts: 369
    Thanks for the responses - I've added another loop in my TP's online event to re-send the level values, at least for now. So far it seems to work, but I really like the idea of updating a structure...that's a quick and easy function call that I can use again and again!
  • viningvining Posts: 4,368
    PhreaK wrote: »
    I'd recommend seperating out your interface code from the system logic and state tracking. In your autopatch comms processing rather then directly updating the UI parse everything and update a structure/array with the relevant values then call a UI update function (which if you want to be really neat, takes the all the data it will need as an argument). That way when your TP comes online you can call the same function and everything will play nice.

    In most cases I prefer to update as the data comes in, one value at a time. I store and I send. I'll also have a function to refresh or update the entire page for occurrances like the original post wanted where you need to bring the enite page up to date when going onto the page or refreshing after a reboot. If a single bit of data comes in I'll just send that data and not call a function that refreshes everything when only one values has changed. Some devices vary so if I just make a switch between an in and an out do I really need to update all the ins and outs that haven't changed?
  • vegastech wrote: »
    ...the level_event changes are lost. I understand that they all get set back to nothing on a reboot. How can I re-send the loop on reboot, without a command being sent to the switcher?

    For my switchers I always create a structure array for the rooms/outputs so that it's easy to store the information as it's updated and resend to the panels when needed.
    DEFINE_TYPE
    STRUCTURE _sRoomInfo
      {
    	 INTEGER  nCurrentSource
    	 SINTEGER nCurrentVolume
    	 CHAR	  cCurrentSourceName[30]
      }
    
    DEFINE_VARIABLE
    _sRoomInfo  _RoomInfo[64]
    

    --John
Sign In or Register to comment.