Home AMX User Forum AMX General Discussion

^RAF command?

"'^RAF-<resource name>,<data>'"

      Add new resources. Adds any and all resource parameters by sending

       embedded codes and data. See below for the Embedded Codes information.

What if the resource already exists? Will it overwrite or do nothing? I know if it exists I can use the ^RMF command to modify it.
"'^RMF-<resource name>'"

      Modify an existing resource.
I want to get away from creating dynamic images in the TPs cuz if you change an IP address for instance it's a pain to update all TPs. So my thinking is in the AxisCamera_Mod I would use the RAF in either define start or the online event but I don't know what happens after that resource has been created, will it just overwrite itself every time which is what I would want in case there's modifications in the code to any of these values. But since there's the ^RMF command for modifications maybe the ^RAF command won't work to re-write.

Comments

  • viningvining Posts: 4,368
    Well apparently I can't get either method to change the resources for my dynamic images. At first I was just sending the ^RAF command but nothing seemed to change so I also started to send the RMF command and still nothing. I figured maybe I should queue the commands and pace their delivery and doesn't help. I uploaded the current file on the TP after this has run and nothing has changed.

    I'm running out of things to try other than deleted all the dynamic images on the TP and trying again, maybe change the %N value to 0 since I'm not sure what is does and I've been trying 1.

    If anyone see any f '-ups in the code please let me know. I've spent the entire afternoon screwing around with this and this has nothing to do with my intended objectives for today, go figure!

    Hmmm, just had a thought, maybe I should send to port 1 of the TP's. Unfortunately I don't recall if this has ever been an issue but it's worth a try.


    DEFINE_FUNCTION fncAxisCam_QueueTPCmd(CHAR iStr[])
    
         {
         cAxisCam_TPCmdQueue = "cAxisCam_TPCmdQueue,iStr" ;
         
         RETURN ;
         }     
         
    DEFINE_FUNCTION fncAxisCam_SendTPCmd(CHAR iStr[])
    
         {
         STACK_VAR INTEGER nFBS ;
         STACK_VAR INTEGER nTPIndx ;
              
         nFBS = find_string(iStr,"'^'",1) ;
         nTPIndx = atoi("GET_BUFFER_STRING(iStr,nFBS-1)") ;
         if(nTPIndx && nTPIndx <= AXIS_NUM_TPs)
    	  {
    	  nFBS = find_string(iStr,"CRLF",1) ;
    	  SET_LENGTH_STRING(iStr,nFBS-1) ;
    	  SEND_COMMAND dvAxisCam_TPArry[nTPIndx],iStr ;
    	  fnAxisCam_DeBug("'SEND TP CMD: ',iStr,'.  >-Line-<',ITOA(__LINE__),'>'") ;
    	  }
         else
    	  {
    	  fnAxisCam_DeBug("'SEND TP CMD ERR! Invalid TP Index.  >-Line-<',ITOA(__LINE__),'>'") ;
    	  }
         RETURN ;
         }  
    
    DATA_EVENT[dvAXISCAM_TPArry]
    
         {
         ONLINE://Main TP Online_Event defaults to Main Page
    	  {
    	  STACK_VAR INTEGER n ;
    	  STACK_VAR INTEGER nFBS ;
    	  STACK_VAR INTEGER nTPIndx ;
    	  STACK_VAR INTEGER nUserPassArryLen ;
    	  STACK_VAR CHAR cTempUser[24] ;
    	  STACK_VAR CHAR cTempPass[24] ;
    	  	  
    	  nTPIndx = GET_LAST(dvAxisCam_TPArry) ;
    	  if(nTPIndx)//just to isolate the rebuild
    	       {
    	       SET_VIRTUAL_LEVEL_COUNT(dvAxisCam_TPArry[nTPIndx],AXIS_NUM_STRUCT_n_LVLs) ;//occasionally had problems w/ non virtual devices too!
    	       REBUILD_EVENT() ;
    	       }
    	  
    	  fnAxisCam_DeBug("fnDEV_TO_STRING(dvAxisCam_TPArry[nTPIndx]),', ONLINE! >-Line-<',ITOA(__LINE__),'>',CRLF") ;
    	 
    	  //protocol    '%P<0-1>'              Set Protocol. HTTP (0) or FTP (1).
    	  //user        '%U<user>'             Set Username for authentication.
    	  //password    '%S<password>'         Set Password for authentication.
    	  //host        '%H<host>'             Set Host name (fully qualified DNS or IP Address).
    	  //path        '%A<path>'             Set Image file path. Set Directory path.The path must be a valid HTTP URL minus the protocol, host, and filename. 
    	  //file        '%F<file>'             Set Image name. Full path to the location of the file or program that will return 
    	  //refresh     '%R<refresh 1-65535>'  Set Refresh rate (in seconds). The number of seconds between refreshes in which the resource is downloaded again. 
    	  //newest      '%N<0-1>'              Set the newest file. A value of 1 means that only the most recent file matching the pattern is downloaded.
    	  //preserve    '%V<0-1>               Set the value of the preserve flag.Default is 0. Currently preserve has no function.
    	  
    	  
    	  nUserPassArryLen = LENGTH_ARRAY(AXISCAM_USERNAME_PASSWORD) ;
    	  
    	  nFBS = find_string(AXISCAM_USERNAME_PASSWORD[1],"':'",1) ;
    	  cTempUser = LEFT_STRING(AXISCAM_USERNAME_PASSWORD[1],nFBS-1) ;
    	  cTempPass = RIGHT_STRING(AXISCAM_USERNAME_PASSWORD[1],LENGTH_STRING(AXISCAM_USERNAME_PASSWORD[1])- nFBS) ;
    	  
    	  for(n = 1 ; n <= AXIS_NUM_CAMERAS ; n ++)
    	       {
    	       if(nUserPassArryLen == AXIS_NUM_CAMERAS && n > 1) //there's one for each camera or just 1 for all no other choices allowed
    		    {
    		    nFBS = find_string(AXISCAM_USERNAME_PASSWORD[n],"':'",1) ;
    		    cTempUser = LEFT_STRING(AXISCAM_USERNAME_PASSWORD[n],nFBS-1) ;
    		    cTempPass = RIGHT_STRING(AXISCAM_USERNAME_PASSWORD[n],LENGTH_STRING(AXISCAM_USERNAME_PASSWORD[n])- nFBS) ;
    		    }
    	       SWITCH(n)
    		    {
    		    CASE 1://resolution=640x480
    		    CASE 2://resolution=320x240
    			 {
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RAF-Camera_',itoa(n),' LG,%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=640x480%R1%N1%V0',CRLF") ;
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RAF-Camera_',itoa(n),',%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=320x240%R1%N1%V0',CRLF") ;
    							    
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RMF-Camera_',itoa(n),' LG,%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=640x480%R1%N1%V0',CRLF") ;
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RMF-Camera_',itoa(n),',%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=320x240%R1%N1%V0',CRLF") ;
    			 
    			 }
    		    CASE 3://resolution=4CIF&compression=50
    		    CASE 4://resolution=CIF
    			 {
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RAF-Camera_',itoa(n),' LG,%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=4CIF&compression=50%R1%N1%V0',CRLF") ;
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RAF-Camera_',itoa(n),',%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=CIF%R1%N1%V0',CRLF") ;
    							    
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RMF-Camera_',itoa(n),' LG,%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=4CIF&compression=50%R1%N1%V0',CRLF") ;
    			 fncAxisCam_QueueTPCmd("itoa(nTPIndx),'^RMF-Camera_',itoa(n),',%P0%U',cTempUser,'%S',cTempPass,'%H',AXISCAM_IP_ADDRESS[n],
    							    '%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=CIF%R1%N1%V0',CRLF") ;
    			 }
    		    }
    	       //SEND_COMMAND dvAxisCam_TPArry[nTPIndx],"'^RMF-Camera_',itoa(n),' LG,%ALab_Test/Images%Ftest.jpg'" ;
    	       }
    	  }
         OFFLINE://if TP falls offline consider it not active, duh!
    	  {
    	  STACK_VAR INTEGER nTPIndx ;
    	  STACK_VAR INTEGER nAxisCam_Indx ;
    	  
    	  nTPIndx = GET_LAST(dvAXISCAM_TPArry) ;
    	  nAxisCam_Indx = nAxisCam_ActiveTPArry[nTPIndx] ;
    	  nAxisCam_ActiveTPArry[nTPIndx] = 0 ;
    	  if(nAxisCam_Indx)//if it wasn't on a camera who cares
    	       {
    	       fnAxis_CheckForActiveTPs(nAxisCam_Indx) ; //checks for other TPs viewing same camera
    	       }
    	  }
         }
     
    DEFINE_PROGRAM
    
    WAIT 5
         {
         if(find_string(cAxisCam_TPCmdQueue,"CRLF",1))
    	  {
    	  fncAxisCam_SendTPCmd(REMOVE_STRING(cAxisCam_TPCmdQueue,"CRLF",1)) ;
    	  }
         }
    
    





    Results in the notifications window:
    Line     44 (18:10:11):: Command To [10001:17:1]-[^RAF-Camera_1 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.077%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=640x480%R1%N1%V0]
    Line     63 (18:10:11):: Command To [10001:17:1]-[^RAF-Camera_1,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.077%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=320x240%R1%N1%V0]
    Line     64 (18:10:12):: Command To [10001:17:1]-[^RMF-Camera_1 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.077%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=640x480%R1%N1%V0]
    Line     65 (18:10:13):: Command To [10001:17:1]-[^RMF-Camera_1,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.077%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=320x240%R1%N1%V0]
    Line     66 (18:10:13):: Command To [10001:17:1]-[^RAF-Camera_2 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.082%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=640x480%R1%N1%V0]
    Line     67 (18:10:14):: Command To [10001:17:1]-[^RAF-Camera_2,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.082%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=320x240%R1%N1%V0]
    Line     68 (18:10:14):: Command To [10001:17:1]-[^RMF-Camera_2 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.082%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=640x480%R1%N1%V0]
    Line     69 (18:10:15):: Command To [10001:17:1]-[^RMF-Camera_2,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.082%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=320x240%R1%N1%V0]
    Line     70 (18:10:15):: Command To [10001:17:1]-[^RAF-Camera_3 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=4CIF&compression=50%R1%N1%V0]
    Line     71 (18:10:16):: Command To [10001:17:1]-[^RAF-Camera_3,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=CIF%R1%N1%V0]
    Line     72 (18:10:16):: Command To [10001:17:1]-[^RMF-Camera_3 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=4CIF&compression=50%R1%N1%V0]
    Line     73 (18:10:17):: Command To [10001:17:1]-[^RMF-Camera_3,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=CIF%R1%N1%V0]
    Line     74 (18:10:17):: Command To [10001:17:1]-[^RAF-Camera_4 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=4CIF&compression=50%R1%N1%V0]
    Line     75 (18:10:18):: Command To [10001:17:1]-[^RAF-Camera_4,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=CIF%R1%N1%V0]
    Line     76 (18:10:18):: Command To [10001:17:1]-[^RMF-Camera_4 LG,%P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=4CIF&compression=50%R1%N1%V0]
    Line     77 (18:10:19):: Command To [10001:17:1]-[^RMF-Camera_4,   %P0%UImmaDaUser%SImmaDaPassword%H192.168.001.042%Aaxis-cgi/mjpg%Fvideo.cgi?resolution=CIF%R1%N1%V0]
    
    
  • DHawthorneDHawthorne Posts: 4,584
    I've used ^RMF to change the dynamic image URL with some success. I say "some" because once in a while, under circumstances I haven't been able to nail down, it still shows the old image. I threw an ^RFRP in there for good measure, but it didn't seem to make much difference. I'm reasonably sure I've also attempted ^RAF, but I can't remember where ... in any case, I've definitely been able to make a "dummy" dynamic image in the panel design, then point it wherever I like in code with ^RMF.
  • snoblesnoble Posts: 35
    There is a known issue with the ^RMF command not triggering an update if the original resource is a Motion JPEG (you can verify that this is your problem by sending the ^RMF, then page flipping away and back again - the image should update). The fix for this will be in the next releases for 8400/i, 700Vi, 1000Vi, 5200i and 500i (unfortunately it just missed the recent 5200i release). Sorry for the inconvenience this is causing.

    As a workaround, you can try sending the ^RMF command, then follow up with a button hide command (^BMF-addr,0,%SW0), then show command (%SW1).

    To answer your original question, the ^RAF command will have no effect if the resource already exists, even if some of the parameters are different. You can try defining all your resources up front (with the ^RAF or in the TPD4 project), then making all subsequent changes via ^RMF (using the above workaround where relevant).
  • viningvining Posts: 4,368
    snoble,

    Add to the fix it list for the ^RMF & possibly the ^RAF command that if you send %H IP strings w/ leading 0's (zeros) in an octet that IP address won't work.

    I've been going back & forth in NS3's "control a device" & eventually I tried sending IP's w/o the 0's and it worked. Now I was only using 0' since it makes my IP Array more uniform & I'm one of those neat freaks. I kept thinking it may be an issue but kept telling myself I was being stupid, they have to resolve addresses w/ 0's in them, it only make sense, right?

    This don't work:

    192.168.001.082

    This do:

    192.168.1.82

    Are you positive ^RAF is ignored if the resource already exist? I think life would be simpler if using the ^RAF command you could create a resource if it doesn't exist but overwrite it (modify) if does. Now I'll have to send both when the TPs come online.

    Could you explain the %N variable. What is it?
  • ericmedleyericmedley Posts: 4,177
    DHawthorne wrote: »
    I've used ^RMF to change the dynamic image URL with some success. I say "some" because once in a while, under circumstances I haven't been able to nail down, it still shows the old image. I threw an ^RFRP in there for good measure, but it didn't seem to make much difference. I'm reasonably sure I've also attempted ^RAF, but I can't remember where ... in any case, I've definitely been able to make a "dummy" dynamic image in the panel design, then point it wherever I like in code with ^RMF.

    I did a system where I tried to make the background image change periodically and pull the images from an ftp server with client pictures on it. It too had similar issues that were hard to nail down. The only consistent symptom was time. It would work like a champ for a while. After some days each panel in the house would slowly loose its ability to change images. It wasn't a wholesale loss of ability either. It would first change sometimes, then less and less until it finally failed to change altogether. There was no rhyme or reason to it seemingly. I telneted into the panels and they would show they were changing the images as ordered, but they weren't.

    Strangely enough, a reboot of any of the component parts (Touch panel(s), Netlinx Master or FTP server) would not get it all working again. You had to do all three. It was one of those things that I've always wanted to fix but ended up just disabling. I thought I'd get back to it some time but never did. Now, the client has sold the property and there's no point now.

    Suffice it to say that there's still some soft baked parts of the implimentation of ^RAF
  • jazzwyldjazzwyld Posts: 199
    just following

    I use RMF all the time in my weather module that polls noaa. I just pull the info from the web page and search for that text for jpg.

    Obviously you have to do a lot of pre-planning, but mine has worked like a champ now for over a year.
  • viningvining Posts: 4,368
    I'm now getting that deja vu feeling of having been there, done that. I believe the last time I was also dealing with NOAA radar & Sat images & I went through the entire gambit of ^RMF,^RAF, ^RFR, ^RFRP and was never really happy with any of those commands as a whole so I ended loading the current images pulled from the internet onto the master into existing filenames that the dynamic images would pull from. I still used some ^RFR & ^RFRP in the code along w/ ^BMP commands but just like today and yesterday I just wasted a whole bunch of time trying to get commands that should be working correctly by now to do what they've been designed to do and advertised they do, do.

    I should start keeping track of how many hours I waste a year trying to get things to work that according to AMX are supposed too but don't or they know they don't and they don't proactively put the word out until it's too late for some of us.

    Ya know If I'm going to loose my certs this year because I refuse to knowingly waste time doing those useless practical exams I think some folks at AMX should loose something too for wasting as much of our time as they do.

    I got my small images to work through code and control device but I still can't get the large files to work which makes me think it's something with the way my string is formatted but with these commands for dynamic images it often is just bugs in the commands. Kinda like the leading 0's in the octets of the IP address, should work but it don't!
  • snoblesnoble Posts: 35
    vining wrote: »
    snoble,

    Add to the fix it list for the ^RMF & possibly the ^RAF command that if you send %H IP strings w/ leading 0's (zeros) in an octet that IP address won't work.

    I've been going back & forth in NS3's "control a device" & eventually I tried sending IP's w/o the 0's and it worked. Now I was only using 0' since it makes my IP Array more uniform & I'm one of those neat freaks. I kept thinking it may be an issue but kept telling myself I was being stupid, they have to resolve addresses w/ 0's in them, it only make sense, right?

    This don't work:

    192.168.001.082

    This do:

    192.168.1.82

    Are you positive ^RAF is ignored if the resource already exist? I think life would be simpler if using the ^RAF command you could create a resource if it doesn't exist but overwrite it (modify) if does. Now I'll have to send both when the TPs come online.

    Could you explain the %N variable. What is it?

    Vining,

    I understand your frustration with the leading zeros - intuitively I would agree with you that they should be discarded. However, historically, operating systems have interpreted leading zeros to mean "Octal notation" (even as recently as Windows 2000 did the same thing, and most ..nix variants still do). To test this, try the octal equivalent of the last 2 octets of your address, which would be 192.168.01.0122. This would be converted to 192.168.1.82 and should work. Obviously, it is highly unlikely anyone would ever do that, so I have written an internal ticket to consider changing this behavior (in your case it is admittedly all the more confounding because 82 is not a valid octal number!). Will keep you posted.

    The ^RAF definitely is ignored if the resource exists (good point though about having a fallback option to modify the resource if it already exists). As for the %N option, it was originally intended to define behavior when FTPing images using wildcards. However, there is currently no alternative to the "newest file" policy (i.e. setting this to 0 does not change the policy), so this option essentially is unused.

    Thanks,
    Scott
    AMX Firmware Engineering
  • viningvining Posts: 4,368
    Snoble,

    Thx for the feedback. I don't know if this has already been addressed & fixed but it used to be that we were unable to use a user & passwords for http type dynamic images stored on the master. If this has been fixed great but if not could you add it to the "to do" list.

    Thx
  • ColzieColzie Posts: 470
    snoble wrote: »
    There is a known issue with the ^RMF command not triggering an update if the original resource is a Motion JPEG (you can verify that this is your problem by sending the ^RMF, then page flipping away and back again - the image should update). The fix for this will be in the next releases for 8400/i, 700Vi, 1000Vi, 5200i and 500i (unfortunately it just missed the recent 5200i release). Sorry for the inconvenience this is causing.

    As a workaround, you can try sending the ^RMF command, then follow up with a button hide command (^BMF-addr,0,%SW0), then show command (%SW1).

    I agree that these type of bugs are super frustrating. If I would have known about this workaround a few years ago....

    On the other hand, I am stoked that AMX is taking care of these types of issues (the button hold problem being another one). To know that AMX cares and is actively cleaning up these things makes me feel all warm and fuzzy. Keep 'em coming!!!
Sign In or Register to comment.