Print

Print


Commit in epics/trunk/epics_example/myexampleApp on MAIN
Db/dbHybLV.db+20-1808 -> 809
src/client_util.c+16-199808 -> 809
   /dbSubExample.c+28-44808 -> 809
+64-244
3 modified files
added a voltage readback record and cleaned up unused functionality.

epics/trunk/epics_example/myexampleApp/Db
dbHybLV.db 808 -> 809
--- epics/trunk/epics_example/myexampleApp/Db/dbHybLV.db	2014-07-22 00:04:39 UTC (rev 808)
+++ epics/trunk/epics_example/myexampleApp/Db/dbHybLV.db	2014-07-22 01:08:00 UTC (rev 809)
@@ -589,7 +589,7 @@
     field(INAM,"subLVInit")
     field(SNAM,"subLVProcess")
     field(SCAN,"Passive")
-    field(FLNK, "SVT:temp:hyb:bot:0:temp0:t_rd")
+    field(FLNK, "SVT:lv:hyb:bot:1:dvdd:v_set_rd")
 }
 
 record(ai, SVT:lv:hyb:bot:3:v125:vf) {
@@ -601,9 +601,27 @@
 
 
 
+####### DVDD V_SET_RD BOT
 
 
+record(sub,SVT:lv:hyb:bot:1:dvdd:v_set_rd_sub)
+{
+    field(INAM,"subLVInit")
+    field(SNAM,"subLVProcess")
+    field(SCAN,"Passive")
+    field(FLNK, "SVT:temp:hyb:bot:0:temp0:t_rd")
+}
 
+record(ai, SVT:lv:hyb:bot:1:dvdd:v_set_rd) {
+  field(SCAN, "Passive") field(PREC, "3")
+  field(FLNK,"SVT:lv:hyb:bot:1:dvdd:v_set_rd_sub")
+  field(INP, "SVT:lv:hyb:bot:1:dvdd:v_set_rd_sub CPP")
+  field(DTYP,"Soft Channel")
+
+}
+
+
+
 ####### DVDD V_SET BOT
 
 
@@ -621,3 +639,4 @@
 }
 
 
+

epics/trunk/epics_example/myexampleApp/src
client_util.c 808 -> 809
--- epics/trunk/epics_example/myexampleApp/src/client_util.c	2014-07-22 00:04:39 UTC (rev 808)
+++ epics/trunk/epics_example/myexampleApp/src/client_util.c	2014-07-22 01:08:00 UTC (rev 809)
@@ -222,56 +222,12 @@
 
 
 
-void getSystemDOM(int* sockfd, xmlDoc** document, xmlNode** root){
 
-/*
-  if(client_util_debug!=0) printf("getSystemDOM\n");
-  //int debug = 0;
-  free_xml_string();
-  if(client_util_debug!=0) printf("Before reading xml string (%p)\n",xml_string_global);
-  read_system_xml_string4(sockfd);
-  //read_system_xml_string2(sockfd,xml_string,300*256);  
-  if(client_util_debug!=0) printf("After reading xml string (%p)\n",xml_string_global);
-  if(xml_string_global!=NULL) {
-    if(client_util_debug!=0) printf("create xml document from xml strlen %ld\n",strlen(xml_string_global));
-    if(strlen(xml_string)>0) {
-      *document = xmlReadMemory(xml_string,strlen(xml_string),"noname.xml",NULL,0);
-      if(client_util_debug!=0) printf("xml doc done %p\n",*document);
-      if(document!=NULL) {
-	*root = xmlDocGetRootElement(*document);
-	if(root!=NULL) {
-	  if(client_util_debug!=0) printf("found root name %s\n",(*root)->name);
-	}
-      } else {
-	if(client_util_debug!=0) printf("problem building xml doc %p\n",*document);	
-      }
-    } else {
-      if(client_util_debug!=0) printf("ERROR: xml_string has zero length!\n");	
-    }
-  } else {
-   if(client_util_debug!=0) printf("ERROR: xml_string is NULL!\n");	
-  }
-*/  
-}
 
 
 
-void writeCalDelay(int* sockfd,char value[],const unsigned int MAX) {
-  
+void writeHybridVTrim(int sockid, int value, int hyb_id, char ch_name[]) {  
   char buffer[256];
-  bzero(buffer,256);
-  int n;
-  sprintf(buffer,"<system><config><cntrlFpga><CalDelay>%s</CalDelay></cntrlFpga></config></system>\f",value);
-  if(client_util_debug) printf("Executing:\"%s\"\n",buffer);
-  n = write(*sockfd,buffer,strlen(buffer));
-  if(n<0) 
-    socket_error("ERROR writing to socket");
-  return;
-
-}
-
-void writeHybridVoltageTrim(int sockid, int value, int hyb_id, char ch_name[]) {  
-  char buffer[256];
   char hyb_tag[256];
   char ch_name_corr[256];
   int n;
@@ -293,6 +249,7 @@
 }
 
 
+
 void writeReadConfig(int sockfd) {
   int n;
   //char buffer[] = "<system><command>ReadConfig</command></system>\f";
@@ -360,8 +317,22 @@
 }
 
 
+void readHybridVTrim(int feb_id, int hyb_id, char ch_name[], char value[],const unsigned int MAX) {  
+  char tag[256];
+  char ch_name_corr[256];
+  memset(tag,0,256);  
+  memset(ch_name_corr,0,256);  
+  // correct name
+  if(strcmp(ch_name,"dvdd")==0) strcpy(ch_name_corr,"Dvdd");
+  if(strcmp(ch_name,"avdd")==0) strcpy(ch_name_corr,"Avdd");
+  if(strcmp(ch_name,"v125")==0) strcpy(ch_name_corr,"V1_25");
+  sprintf(tag,"system:config:FrontEndTestFpga:FebCore:Hybrid%d%sTrim",hyb_id,ch_name_corr);
+  getXMLValue(tag,value,MAX);
+  return;  
+}
 
 
+
 xmlNode* retrieveElement(xmlDoc* doc, xmlNode* node, char* tag) {
   xmlNode* cur_node = NULL;
   xmlNode* found_it = NULL;
@@ -397,164 +368,10 @@
 
 
 
-void read_system_xml_string3(int* socketfd, char buffer[], const int MAX) {
-  printf("read xml3 buffer at %p and buffer length %d\n",buffer,MAX);
-  const unsigned int READ_BUFFER_SIZE = 65536;
-  const float wait_interval_usec = 100000;  
-  char buffer_read[MAX];
-  char buf[READ_BUFFER_SIZE];
-  int read_i = 0;
-  int read_n;
-  int debug = client_util_debug;
-  int n_endings = 0;
-  int offset = 0;
-  printf("time\n");
-  clock_t start_time;
-  clock_t diff;
-  //reset
-  printf(" reset buffer1\n");
-  //bzero(buffer_read,MAX);
-  memset(buffer_read,0,MAX);
-  printf(" reset buffer2\n");
-  bzero(buf,READ_BUFFER_SIZE);
-  printf(" reset buffer3\n");
-  //bzero(buffer,MAX);
-  memset(buffer,0,MAX);
-  //if(debug>0) 
-  printf("read xml3 debug=%d\n",debug);
-  start_time = clock();
-  diff = (start_time - start_time);
 
-  if(debug>0) printf("start_time at %f clocks\n",(float)start_time);
-  
-  while(((float)(diff/CLOCKS_PER_SEC))<5.0) { 
-    if(debug>0) printf("at read_i %d clocks %f time %f\n",read_i,(float)diff,(float)((float)diff)/CLOCKS_PER_SEC);
-    
-    bzero(buf,READ_BUFFER_SIZE);
-    
-    read_n = 0;
-    ioctl(*socketfd, FIONREAD, &read_n);
-    
-    if(debug>0) {
-      printf("%d available on socket\n",read_n);
-    }
-    
-    if(read_n>0) {      
-      if(read_n>READ_BUFFER_SIZE) {
-	read_n = READ_BUFFER_SIZE-1;
-      }
-      
-      read_n = read((*socketfd),buf,read_n);
-      
-      if(debug>0) printf("read_n %d\n",read_n);
-      
-      if (read_n < 0) {
-	printf("ERROR reading from socket");
-	exit(1);
-      }
-      
-      //if(debug!=0) printf("buf:\n%s\n",buf);
-      
-      //       if(strchr(buf,'\f')!=0) { 
-      // if(debug>0) printf("found ending in this buf!\n"); 
-      // n_endings++; 
-      //       } 
-      char *pch;
-      pch = strchr(buf,'\f');
-      while(pch!=NULL) {
-	if(debug>0) printf("found ending at %p (array index %ld) in this buf!\n",pch,pch-buf);
-	n_endings++;
-	pch = strchr(pch+1,'\f');
-      }
-      
-      //check for overflow before copying
-      if((offset+read_n) >= MAX) {
-	printf("\nread offset %d exceeds available buffer length %d at  read_i %d\n",offset+read_n, MAX,read_i);
-	return;
-      }
-      
-      if(debug!=0) printf("\ncopy buf of size %d to %d offset (MAX=%d) after %p\n",read_n,offset,MAX,buffer_read);
-      
-      memcpy(buffer_read+offset,buf,read_n);
-      //strcpy(buffer_read+offset,buf);
-      
-      // update offset
-      //offset = offset + strlen(buf);
-      offset = offset + read_n;
-      //buffer_read[read_i*READ_BUFFER_SIZE+READ_BUFFER_SIZE] = NULL;
-      
-      if(debug!=0) {
-	printf("\nlen of string is %u after read_i %d:\n%s\n",(unsigned)strlen(buffer_read),read_i,buffer_read);
-	int ktmp;
-	for(ktmp=read_n-100;ktmp<(read_n+100);ktmp++) printf("ktmp: '%c'\n",buffer_read[ktmp]);
-      }
-      
-    } // read_n>0
-    else {
-      if(debug!=0) printf("Nothing to read from socket. Sleep a little\n");      
-      usleep(wait_interval_usec);
-      //sleep(1);
-    } 
-    
-    
-    
-    if(n_endings>=2) {
-      if(debug!=0) printf("\nfound two endings at read_i %u with total len %u\n",read_i,(unsigned)strlen(buffer_read));      
-      break;
-    }
-    
-    
-    // check timing
-    diff = clock()-start_time;
-    //if(diff/CLOCKS_PER_SEC > 5.0) {
-    //if(debug!=0) printf("\n after read_i %u nr clocks %f diff %f to read from socket\n",(unsigned)read_i,(float)diff,(float)((float)diff)/CLOCKS_PER_SEC);
-    //break;    
-    //}
-    
-    //if(read_i>10000) {
-    //  if(debug!=0) printf("\ntoo many reads, error getting xml string at read_i %d\n",read_i);
-    //  break;
-    //}
 
-    ++read_i;
-  }
-  
-  if(n_endings==2) {
-    
-    if(debug!=0) printf("\nPick out string between endings \n%s\n",buffer_read);
-    // start at first system tag
-    if(debug!=0) printf("\nlen %u\n",(unsigned)strlen(buffer_read));
-    char* start = strstr(buffer_read,"<system>");
-    //char* start = strchr(buffer_read,'\f');
-    //char* end2 = strchr(buffer_read,'\f');
-    char* end2 = NULL;
-    if(start!=NULL) {
-      if(debug!=0) printf("\nstart at %p offset %ld\n",start,start-buffer_read);
-      if(end2!=NULL) {
-	if(debug!=0) printf("\n end2 at %p offset %ld\n",end2,end2-buffer_read);
-      }
-      char* end = strchr(start,'\f');
-      if(end!=NULL) {
-	if(debug!=0) printf("\nend at %p\n",end);
-	memcpy(buffer,start,end-start);
-	buffer[end-(start+1)+1] = '\0'; // terminate it
-	if(debug!=0) printf("\ncopied %ld chars to %p\n%s\n",end-(start+1),buffer,buffer);
-      } else {
-	if(debug!=0) printf("\n no end found\n");
-      }
-    } else {
-      if(debug!=0) printf("\n no start found found\n");
-    }
-    
-  }
 
-  return;
 
-}
-
-
-
-
 int findSystemStr(char* buf, const int MAX, char** start) {
   if(client_util_debug>1) printf("finding system string from %p and %d chars len with start at %p\n",buf,MAX,*start);
   char* s = strstr(buf,"<system>");  

epics/trunk/epics_example/myexampleApp/src
dbSubExample.c 808 -> 809
--- epics/trunk/epics_example/myexampleApp/src/dbSubExample.c	2014-07-22 00:04:39 UTC (rev 808)
+++ epics/trunk/epics_example/myexampleApp/src/dbSubExample.c	2014-07-22 01:08:00 UTC (rev 809)
@@ -14,7 +14,6 @@
 int mySubDebug = 0;
 int process_order = 0;
 const int BUF_SIZE = 256;
-//char hostName[256] = "";// "134.79.229.141";
 char* hostNameDef = "134.79.229.141";
 char hostName[256];
 int portDef = 8091;
@@ -50,63 +49,45 @@
     printf("%d: Record %s called setupSocket(%p)\n", process_order, precord->name, (void*) precord);
   }
 
-  if(strcmp(precord->name,"SVT:poll_xml")==0) {
-    
+  // only setup socket from DB if it's the poll record?
+  if(strcmp(precord->name,"SVT:poll_xml")==0) {    
     // look for host name and port in DB
     //initialize the string
-    //memset(hostName,0,BUF_SIZE);  
-    //port=0;
     struct link* inpa;
     struct link* inpb;
     inpa = &precord->inpa;
     inpb = &precord->inpb;
-    if(inpa && inpb) {
-      if(inpa && inpb) {
-	//union value va = inpa->value;
-	//union value vb = inpb->value;
-	if (mySubDebug) { 
-	  printf("inpa type %d value %p %s\n",inpa->type,inpa->value.constantStr,inpa->value.constantStr);
-	  printf("inpb type %d value %p %s\n",inpb->type,inpb->value.constantStr,inpb->value.constantStr);  
-	  printf("inpa pv_link name %p\n",(inpa->value).pv_link.pvname);
-	  printf("inpa pv_link name %s\n",(inpa->value).pv_link.pvname);
-	}
-	if(inpa->value.pv_link.pvname && inpb->value.pv_link.pvname) {
-	  //struct dbCommon* recA = ((inpa->value).pv_link).precord;
-	  struct stringinRecord* recA = (stringinRecord*) ((inpa->value).pv_link).precord;
-	  if (mySubDebug) printf("inpa pv_link record %p name %s\n",recA, recA->name);
-	  char* stra = recA->val;
-	  if (mySubDebug) printf("stra %p %s %c\n",stra,stra,stra[0]);
-	  strcpy(hostName,stra);
-	  if (mySubDebug) printf("got hostname \"%s\"\n",hostName);
-	  struct longinRecord* recB = (longinRecord*) ((inpa->value).pv_link).precord;
-	  if (mySubDebug) printf("inpb pv_link record %p name %s\n",recB, recB->name);
-	  port = recB->val;
-	} else {
-	  printf("inpa and inpb value are null when getting host and port\n");
-	}
-      } else {
-	printf("inpa and inpb strings are null when getting host and port\n");
-      }
-      
-    } else {
-      printf("inpa and inpb are null when getting host and port\n");
+    if (mySubDebug) { 
+      printf("inpa type %d value %p %s\n",inpa->type,inpa->value.constantStr,inpa->value.constantStr);
+      printf("inpb type %d value %p %s\n",inpb->type,inpb->value.constantStr,inpb->value.constantStr);  
+      printf("inpa pv_link name %p\n",(inpa->value).pv_link.pvname);
+      printf("inpa pv_link name %s\n",(inpa->value).pv_link.pvname);
     }
+    if(inpa->value.pv_link.pvname && inpb->value.pv_link.pvname) {
+      struct stringinRecord* recA = (stringinRecord*) ((inpa->value).pv_link).precord;
+      if (mySubDebug) printf("inpa pv_link record %p name %s\n",recA, recA->name);
+      char* stra = recA->val;
+      if (mySubDebug) printf("stra %p %s '%c' '%c' '%c'\ \n",stra,stra,stra[0],stra[1],stra[2]);
+      strcpy(hostName,stra);
+      if (mySubDebug) printf("got hostname \"%s\"\n",hostName);
+      struct longinRecord* recB = (longinRecord*) ((inpa->value).pv_link).precord;
+      if (mySubDebug) printf("inpb pv_link record %p name %s\n",recB, recB->name);
+      port = recB->val;
+    } else {
+      printf("inpa and inpb value are null when getting host and port\n");
+    }      
   }
   
-  if(strlen(hostName)==0) {
-    printf("No hostname found in DB. Use default\n");
+  if(strlen(hostName)==0 || port==0) {
+    printf("No hostname or port found in DB. Use default\n");
     strcpy(hostName,hostNameDef);
-  }
-  if(port==0) {
-    printf("No port found in DB. Use default\n");
     port = portDef;
   }
   
   if(strcmp(hostName,"")==0) {
     printf("ERROR no valid hostname found\n");
     return;
-  }
-  
+  }  
   if (mySubDebug) {
     printf("hostName %s port %d\n",hostName,port);  
   }
@@ -149,7 +130,7 @@
 
   if(strcmp(action,"v_set_sub")==0) {    
     if(precord->val<255 && precord->val>0) {
-      writeHybridVoltageTrim(sockfd,(int)precord->val, id, ch_name);    
+      writeHybridVTrim(sockfd,(int)precord->val, id, ch_name);    
 
 
       if (mySubDebug) {
@@ -224,6 +205,9 @@
   else if(strcmp(action,"vf_sub")==0) {
     readHybridV(feb_id, id, ch_name, "Far", value, BUF_SIZE);
   } 
+  else if(strcmp(action,"v_set_rd_sub")==0) {
+    readHybridVTrim(feb_id, id, ch_name, value, BUF_SIZE);
+  } 
   else {
     printf("wrong action for readHybrid \"%s\"\n",action);
     return;
@@ -327,7 +311,7 @@
       printf("ERROR wrong option for hybrid ch: %s\n",ch_name);
       return 0;
     }
-    if(strcmp(action,"vn_sub")==0 || strcmp(action,"vf_sub")==0 || strcmp(action,"i_rd_sub")==0) {
+    if(strcmp(action,"vn_sub")==0 || strcmp(action,"vf_sub")==0 || strcmp(action,"i_rd_sub")==0 || strcmp(action,"v_set_rd_sub")==0) {
       readHybrid(precord,action,(int)li_id,feb_id,ch_name);  
     } else if(strcmp(action,"v_set_sub")==0) { 
       writeHybrid(precord,action,(int)li_id,feb_id,ch_name);  
SVNspam 0.1