epics/trunk/epics_example/myexampleApp/src
--- epics/trunk/epics_example/myexampleApp/src/dbSubExample.c 2014-07-18 20:51:06 UTC (rev 797)
+++ epics/trunk/epics_example/myexampleApp/src/dbSubExample.c 2014-07-18 20:53:41 UTC (rev 798)
@@ -22,8 +22,9 @@
int sockfd = 0;
int counter = 0;
const double def_hyb_v = -1.0;
-const double def_hyb_i = -2.0;
-const double def_AxiXadcTemp = -1.0;
+const double def_hyb_i = -1.0;
+const double def_hyb_t = -999.9;
+const double def_AxiXadcTemp = -999.9;
static long subLVInit(subRecord *precord) {
process_order++;
@@ -121,17 +122,15 @@
-
-
- static void readHybrid(subRecord* precord,char action[], char half[],int id, int feb_id, char ch_name[])
+ static void readHybrid(subRecord* precord,char action[], int id, int feb_id, char ch_name[])
{
double constant;
if(mySubDebug) {
- printf("Record %s called readHybrid %s for half=%s id=%d ch_name=%s\n", precord->name,action,half,id,ch_name);
+ printf("Record %s called readHybrid %s for feb_id= %d id=%d ch_name=%s\n", precord->name,action,feb_id,id,ch_name);
}
//set to default
- precord->val = def_hyb_i;
+ precord->val = def_hyb_t;
char value[BUF_SIZE];
memset(value,0,BUF_SIZE);
@@ -141,7 +140,17 @@
constant = 1e3;
}
else if(strcmp(action,"t_rd_sub")==0) {
- int tId = atoi(ch_name);
+ int tId;
+ if(strcmp(ch_name,"temp0")==0) {
+ tId = 0;
+ }
+ else if(strcmp(ch_name,"temp1")==0) {
+ tId = 1;
+ }
+ else {
+ printf("ERROR: in readHybrid: the ch_name %s for action %s is not defined!\n",ch_name,action);
+ exit(1);
+ }
readHybridT(feb_id, id, tId, value, BUF_SIZE);
}
else if(strcmp(action,"vn_sub")==0) {
@@ -171,14 +180,14 @@
printf("Record %s called readFeb %s feb_id=%d ch_name=%s\n",precord->name,action,feb_id,ch_name);
}
- //set to default
- precord->val=def_AxiXadcTemp;
char value[BUF_SIZE];
memset(value,0,BUF_SIZE);
if(strcmp(action,"t_rd_sub")==0) {
+ //set to default
+ precord->val=def_AxiXadcTemp;
readFebT(feb_id, value, ch_name, BUF_SIZE);
-
+
}
else {
printf("No such action %s implemented for readFeb!\n",action);
@@ -267,16 +276,24 @@
printf("ERROR this type is not valid \"%s\"\n",type);
return 0;
}
-
-
- // use default value until the DAQ map can be added
- if(strcmp(half,"bot")==0) {
- feb_id = 0;
+
+ char* p_end = id;
+ long int li_id = strtol(id,&p_end,0);
+ if(p_end!=id) {
+ if(li_id<0 && li_id>17) {
+ printf("ERROR this hybrid id %ld is not valid\n",li_id);
+ return 0;
+ }
} else {
- printf("ERROR only bot half can be used. Need to implement DAQ map!\n");
+ printf("ERROR converting this hybrid id %s is not valid\n",id);
+ return 0;
+ }
+ feb_id = getFebIdFromDaqMap((int)li_id,half);
+ if(feb_id<0) {
+ printf("ERROR getting feb id\n");
return 0;
- }
-
+ }
+
if(strcmp(board_type,"hyb")==0) {
if(strcmp(ch_name,"dvdd")!=0 && strcmp(ch_name,"avdd")!=0 && strcmp(ch_name,"v125")!=0) {
printf("ERROR wrong option for hybrid ch: %s\n",ch_name);
@@ -286,25 +303,11 @@
printf("ERROR this hybrid action type is not valid \"%s\"\n",action);
return 0;
}
- char* p_end = id;
- long int li_id = strtol(id,&p_end,0);
- if(p_end!=id) {
- if(li_id<0 && li_id>17) {
- printf("ERROR this hybrid id %ld is not valid\n",li_id);
- return 0;
- }
- } else {
- printf("ERROR converting this hybrid id %s is not valid\n",id);
- return 0;
- }
- readHybrid(precord,action,half,(int)li_id,feb_id,ch_name);
+
+ readHybrid(precord,action,(int)li_id,feb_id,ch_name);
}
- else if(strcmp(board_type,"fe")==0) {
- printf("No LV implementation exists for feb\n");
- return 0;
- }
else {
- printf("ERROR this board type is not valid \"%s\"\n",board_type);
+ printf("ERROR this board type is not valid \"%s\" for LV\n",board_type);
return 0;
}
@@ -354,19 +357,11 @@
getChName(precord->name,ch_name,BUF_SIZE);
getAction(precord->name,action,BUF_SIZE);
- if(strcmp(ch_name,"temp1")!=0 && strcmp(ch_name,"temp2")!=0) {
+ if(strcmp(ch_name,"temp0")!=0 && strcmp(ch_name,"temp1")!=0) {
printf("ERROR wrong option for hybrid ch: %s\n",ch_name);
return 0;
}
-
- // use default value until the DAQ map can be added
- if(strcmp(half,"bot")==0) {
- feb_id = 0;
- } else {
- printf("ERROR only bot half can be used. Need to implement DAQ map!\n");
- return 0;
- }
char* p_end = id;
long int li_id = strtol(id,&p_end,0);
if(p_end!=id) {
@@ -379,9 +374,16 @@
return 0;
}
- readHybrid(precord,action,half,(int)li_id,feb_id,ch_name);
+ feb_id = getFebIdFromDaqMap((int)li_id,half);
+ if(feb_id<0) {
+ printf("ERROR getting feb id\n");
+ return 0;
+ }
+
+ readHybrid(precord,action,(int)li_id,feb_id,ch_name);
+
}
else if(strcmp(board_type,"fe")==0) {
sprintf(half,"%s","bot");