⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gatepv.cc

📁 EPICS CA gateway, base on channel access protocol
💻 CC
📖 第 1 页 / 共 4 页
字号:
	else	{		// problems with the PV if status code not normal - attempt monitor		// should check if Monitor() fails and send remove trans if		// needed		if(pv->active()) pv->monitor();	}}void gatePvData::accessCB(ACCESS_ARGS args){	gatePvData* pv=(gatePvData*)ca_puser(args.chid);	gateVcData* vc=pv->VC();#ifdef RATE_STATS	++pv->mrg->client_event_count;#endif#if DEBUG_DELAY	if(!strncmp("Xorbit",pv->name(),6)) {		printf("%s gatePvData::accessCB: %s vc=%d state=%d\n",timeStamp(),		  pv->name(),vc,pv->getState());	}#endif	// sets general read/write permissions for the gateway itself	if(vc)	{		vc->setReadAccess(ca_read_access(args.chid)?aitTrue:aitFalse);		vc->setWriteAccess(ca_write_access(args.chid)?aitTrue:aitFalse);	}	gateDebug0(9,"accCB: -------------------------------\n");	gateDebug1(9,"accCB: name=%s\n",ca_name(args.chid));	gateDebug1(9,"accCB: type=%d\n",ca_field_type(args.chid));	gateDebug1(9,"accCB: number of elements=%ld\n",	  (long)ca_element_count(args.chid));	gateDebug1(9,"accCB: host name=%s\n",ca_host_name(args.chid));	gateDebug1(9,"accCB: read access=%d\n",ca_read_access(args.chid));	gateDebug1(9,"accCB: write access=%d\n",ca_write_access(args.chid));	gateDebug1(9,"accCB: state=%d\n",ca_state(args.chid));}// one function for each of the different data that come from gets://  DBR_STS_STRING//  DBR_CTRL_ENUM//  DBR_CTRL_CHAR//  DBR_CTRL_DOUBLE//  DBR_CTRL_FLOAT//  DBR_CTRL_LONG//  DBR_CTRL_SHORT (DBR_CTRL_INT)gdd* gatePvData::dataStringCB(void * /*dbr*/){	gateDebug0(4,"gatePvData::dataStringCB\n");	// no useful pv_data returned by this function	return NULL;}gdd* gatePvData::dataEnumCB(void * dbr){	gateDebug0(4,"gatePvData::dataEnumCB\n");	int i;	dbr_ctrl_enum* ts = (dbr_ctrl_enum*)dbr;	aitFixedString* items = new aitFixedString[ts->no_str];	gddAtomic* menu=new gddAtomic(GR->appEnum,aitEnumFixedString,1,ts->no_str);#if DEBUG_ENUM	printf("gatePvData::dataEnumCB: no_str=%d\n",ts->no_str);	for(i=0; i<ts->no_str; i++) {		printf("  %s\n",ts->strs[i]);	}#endif	// DBR_CTRL_ENUM response	for (i=0;i<ts->no_str;i++) {		strncpy(items[i].fixed_string,&(ts->strs[i][0]),		  sizeof(aitFixedString));		items[i].fixed_string[sizeof(aitFixedString)-1u] = '\0';	}	menu->putRef(items,new gateFixedStringDestruct());#if DEBUG_ENUM#endif	return menu;}gdd* gatePvData::dataDoubleCB(void * dbr){	gateDebug0(10,"gatePvData::dataDoubleCB\n");	dbr_ctrl_double* ts = (dbr_ctrl_double*)dbr;	gdd* attr = GETDD(appAttributes);	// DBR_CTRL_DOUBLE response	attr[gddAppTypeIndex_attributes_units].put(ts->units);	attr[gddAppTypeIndex_attributes_maxElements]=maxElements();	attr[gddAppTypeIndex_attributes_precision]=ts->precision;	attr[gddAppTypeIndex_attributes_graphicLow]=ts->lower_disp_limit;	attr[gddAppTypeIndex_attributes_graphicHigh]=ts->upper_disp_limit;	attr[gddAppTypeIndex_attributes_controlLow]=ts->lower_ctrl_limit;	attr[gddAppTypeIndex_attributes_controlHigh]=ts->upper_ctrl_limit;	attr[gddAppTypeIndex_attributes_alarmLow]=ts->lower_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmHigh]=ts->upper_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmLowWarning]=ts->lower_warning_limit;	attr[gddAppTypeIndex_attributes_alarmHighWarning]=ts->upper_warning_limit;	return attr;}gdd* gatePvData::dataShortCB(void *dbr){	gateDebug0(10,"gatePvData::dataShortCB\n");	dbr_ctrl_short* ts = (dbr_ctrl_short*)dbr;	gdd* attr = GETDD(appAttributes);	// DBR_CTRL_SHORT DBT_CTRL_INT response	attr[gddAppTypeIndex_attributes_units].put(ts->units);	attr[gddAppTypeIndex_attributes_maxElements]=maxElements();	attr[gddAppTypeIndex_attributes_precision]=0;	attr[gddAppTypeIndex_attributes_graphicLow]=ts->lower_disp_limit;	attr[gddAppTypeIndex_attributes_graphicHigh]=ts->upper_disp_limit;	attr[gddAppTypeIndex_attributes_controlLow]=ts->lower_ctrl_limit;	attr[gddAppTypeIndex_attributes_controlHigh]=ts->upper_ctrl_limit;	attr[gddAppTypeIndex_attributes_alarmLow]=ts->lower_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmHigh]=ts->upper_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmLowWarning]=ts->lower_warning_limit;	attr[gddAppTypeIndex_attributes_alarmHighWarning]=ts->upper_warning_limit;	return attr;}gdd* gatePvData::dataFloatCB(void *dbr){	gateDebug0(10,"gatePvData::dataFloatCB\n");	dbr_ctrl_float* ts = (dbr_ctrl_float*)dbr;	gdd* attr = GETDD(appAttributes);	// DBR_CTRL_FLOAT response	attr[gddAppTypeIndex_attributes_units].put(ts->units);	attr[gddAppTypeIndex_attributes_maxElements]=maxElements();	attr[gddAppTypeIndex_attributes_precision]=ts->precision;	attr[gddAppTypeIndex_attributes_graphicLow]=ts->lower_disp_limit;	attr[gddAppTypeIndex_attributes_graphicHigh]=ts->upper_disp_limit;	attr[gddAppTypeIndex_attributes_controlLow]=ts->lower_ctrl_limit;	attr[gddAppTypeIndex_attributes_controlHigh]=ts->upper_ctrl_limit;	attr[gddAppTypeIndex_attributes_alarmLow]=ts->lower_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmHigh]=ts->upper_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmLowWarning]=ts->lower_warning_limit;	attr[gddAppTypeIndex_attributes_alarmHighWarning]=ts->upper_warning_limit;	return attr;}gdd* gatePvData::dataCharCB(void *dbr){	gateDebug0(10,"gatePvData::dataCharCB\n");	dbr_ctrl_char* ts = (dbr_ctrl_char*)dbr;	gdd* attr = GETDD(appAttributes);	// DBR_CTRL_CHAR response	attr[gddAppTypeIndex_attributes_units].put(ts->units);	attr[gddAppTypeIndex_attributes_maxElements]=maxElements();	attr[gddAppTypeIndex_attributes_precision]=0;	attr[gddAppTypeIndex_attributes_graphicLow]=ts->lower_disp_limit;	attr[gddAppTypeIndex_attributes_graphicHigh]=ts->upper_disp_limit;	attr[gddAppTypeIndex_attributes_controlLow]=ts->lower_ctrl_limit;	attr[gddAppTypeIndex_attributes_controlHigh]=ts->upper_ctrl_limit;	attr[gddAppTypeIndex_attributes_alarmLow]=ts->lower_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmHigh]=ts->upper_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmLowWarning]=ts->lower_warning_limit;	attr[gddAppTypeIndex_attributes_alarmHighWarning]=ts->upper_warning_limit;	return attr;}gdd* gatePvData::dataLongCB(void *dbr){	gateDebug0(10,"gatePvData::dataLongCB\n");	dbr_ctrl_long* ts = (dbr_ctrl_long*)dbr;	gdd* attr = GETDD(appAttributes);	// DBR_CTRL_LONG response	attr[gddAppTypeIndex_attributes_units].put(ts->units);	attr[gddAppTypeIndex_attributes_maxElements]=maxElements();	attr[gddAppTypeIndex_attributes_precision]=0;	attr[gddAppTypeIndex_attributes_graphicLow]=ts->lower_disp_limit;	attr[gddAppTypeIndex_attributes_graphicHigh]=ts->upper_disp_limit;	attr[gddAppTypeIndex_attributes_controlLow]=ts->lower_ctrl_limit;	attr[gddAppTypeIndex_attributes_controlHigh]=ts->upper_ctrl_limit;	attr[gddAppTypeIndex_attributes_alarmLow]=ts->lower_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmHigh]=ts->upper_alarm_limit;	attr[gddAppTypeIndex_attributes_alarmLowWarning]=ts->lower_warning_limit;	attr[gddAppTypeIndex_attributes_alarmHighWarning]=ts->upper_warning_limit;	return attr;}// one function for each of the different events that come from monitors://  DBR_TIME_STRING//  DBR_TIME_ENUM//  DBR_TIME_CHAR//  DBR_TIME_DOUBLE//  DBR_TIME_FLOAT//  DBR_TIME_LONG//  DBR_TIME_SHORT (DBR_TIME_INT)//  DBR_STSACK_STRING (alarm info)gdd* gatePvData::eventStringCB(void *dbr){	gateDebug0(10,"gatePvData::eventStringCB\n");	dbr_time_string* ts = (dbr_time_string*)dbr;	aitIndex count = totalElements();	gdd* value;	// DBR_TIME_STRING response	if(count>1)	{		// KE: For arrays of strings.  This case was not originally		// included and was added 11-2004.  It uses aitFixedString		// whereas the count=1 case uses aitString, which is a class.		// It is not commonly used, so if this implementation is		// wrong, it may be awhile before it is discovered.		aitFixedString *d,*nd;		nd=new aitFixedString[count];		d=(aitFixedString*)&ts->value;		memcpy(nd,d,count*sizeof(aitFixedString));		value=new gddAtomic(GR->appValue,aitEnumFixedString,1,&count);		value->putRef(nd,new gateFixedStringDestruct());	}	else	{		value=new gddScalar(GR->appValue, aitEnumString);		aitString* str = (aitString*)value->dataAddress();		str->copy(ts->value);	}	value->setStatSevr(ts->status,ts->severity);	value->setTimeStamp(&ts->stamp);	return value;}gdd* gatePvData::eventEnumCB(void *dbr){	gateDebug0(10,"gatePvData::eventEnumCB\n");	dbr_time_enum* ts = (dbr_time_enum*)dbr;	aitIndex count = totalElements();	gdd* value;#if DEBUG_ENUM	printf("gatePvData::eventEnumCB\n");#endif	// DBR_TIME_ENUM response	if(count>1)	{		// KE: For arrays of enums.  This case was not originally		// included and was added 11-2004.  It is not commonly, if		// ever, used, so if this implementation is wrong, it may be		// awhile before it is discovered.  The waveform can be an		// array of enums (FTVL="ENUM"), but there is no support for		// the menu strings, so this is an unwise thing to do.  Note		// that the menu strings (which don't exist for the waveform)		// are added in dataEnumCB.		aitEnum16 *d,*nd;		nd=new aitEnum16[count];		d=(aitEnum16*)&ts->value;		memcpy(nd,d,count*sizeof(aitEnum16));		value=new gddAtomic(GR->appValue,aitEnumInt16,1,&count);		value->putRef(nd,new gateEnumDestruct());	}	else	{		value = new gddScalar(GR->appValue,aitEnumEnum16);		value->putConvert(ts->value);	}#if DEBUG_ENUM	printf("gatePvData::eventEnumCB\n");	value->dump();#endif	value->setStatSevr(ts->status,ts->severity);	value->setTimeStamp(&ts->stamp);	return value;}gdd* gatePvData::eventLongCB(void *dbr){	gateDebug0(10,"gatePvData::eventLongCB\n");	dbr_time_long* ts = (dbr_time_long*)dbr;	aitIndex count = totalElements();	gdd* value;	// DBR_TIME_LONG response	// set up the value	if(count>1)	{		aitInt32 *d,*nd;		nd=new aitInt32[count];		d=(aitInt32*)&ts->value;		memcpy(nd,d,count*sizeof(aitInt32));		value=new gddAtomic(GR->appValue,aitEnumInt32,1,&count);		value->putRef(nd,new gateIntDestruct());	}	else	{		value = new gddScalar(GR->appValue,aitEnumInt32);		*value=ts->value;	}	value->setStatSevr(ts->status,ts->severity);	value->setTimeStamp(&ts->stamp);	return value;}gdd* gatePvData::eventCharCB(void *dbr){	gateDebug0(10,"gatePvData::eventCharCB\n");	dbr_time_char* ts = (dbr_time_char*)dbr;	aitIndex count = totalElements();	gdd* value;	// DBR_TIME_CHAR response	// set up the value	if(count>1)	{		aitInt8 *d,*nd;		nd=new aitInt8[count];		d=(aitInt8*)&(ts->value);		memcpy(nd,d,count*sizeof(aitInt8));		value = new gddAtomic(GR->appValue,aitEnumInt8,1,&count);		value->putRef(nd,new gateCharDestruct());	}	else	{		value = new gddScalar(GR->appValue,aitEnumInt8);		*value=ts->value;	}	value->setStatSevr(ts->status,ts->severity);	value->setTimeStamp(&ts->stamp);	return value;}gdd* gatePvData::eventFloatCB(void *dbr){	gateDebug0(10,"gatePvData::eventFloatCB\n");	dbr_time_float* ts = (dbr_time_float*)dbr;	aitIndex count = totalElements();	gdd* value;	// DBR_TIME_FLOAT response	// set up the value	if(count>1)	{		aitFloat32 *d,*nd;		nd=new aitFloat32[count];		d=(aitFloat32*)&(ts->value);		memcpy(nd,d,count*sizeof(aitFloat32));		value= new gddAtomic(GR->appValue,aitEnumFloat32,1,&count);		value->putRef(nd,new gateFloatDestruct());	}	else	{		value = new gddScalar(GR->appValue,aitEnumFloat32);		*value=ts->value;	}	value->setStatSevr(ts->status,ts->severity);	value->setTimeStamp(&ts->stamp);	return value;}gdd* gatePvData::eventDoubleCB(void *dbr){	gateDebug0(10,"gatePvData::eventDoubleCB\n");	dbr_time_double* ts = (dbr_time_double*)dbr;	aitIndex count = totalElements();	gdd* value;	// DBR_TIME_FLOAT response	// set up the value	if(count>1)	{		aitFloat64 *d,*nd;		nd=new aitFloat64[count];		d=(aitFloat64*)&(ts->value);		memcpy(nd,d,count*sizeof(aitFloat64));		value= new gddAtomic(GR->appValue,aitEnumFloat64,1,&count);		value->putRef(nd,new gateDoubleDestruct());	}	else	{		value = new gddScalar(GR->appValue,aitEnumFloat64);		*value=ts->value;	}	value->setStatSevr(ts->status,ts->severity);	value->setTimeStamp(&ts->stamp);	return value;}gdd* gatePvData::eventShortCB(void *dbr){	gateDebug0(10,"gatePvData::eventShortCB\n");	dbr_time_short* ts = (dbr_time_short*)dbr;	aitIndex count = totalElements();	gdd* value;	// DBR_TIME_FLOAT response	// set up the value	if(count>1)	{		aitInt16 *d,*nd;		nd=new aitInt16[count];		d=(aitInt16*)&(ts->value);		memcpy(nd,d,count*sizeof(aitInt16));		value=new gddAtomic(GR->appValue,aitEnumInt16,1,&count);		value->putRef(nd,new gateShortDestruct);	}	else	{		value = new gddScalar(GR->appValue,aitEnumInt16);		*value=ts->value;	}	value->setStatSevr(ts->status,ts->severity);	value->setTimeStamp(&ts->stamp);	return value;}gdd* gatePvData::eventSTSAckStringCB(dbr_stsack_string *ts){	gateDebug0(10,"gatePvData::eventSTSAckStringCB\n");	gdd* dd = GETDD(appSTSAckString);	gdd& vdd = dd[gddAppTypeIndex_dbr_stsack_string_value];	// DBR_STSACK_STRING response	// (the value gdd carries the severity and status information)	dd[gddAppTypeIndex_dbr_stsack_string_ackt] = ts->ackt;	dd[gddAppTypeIndex_dbr_stsack_string_acks] = ts->acks;	aitString* str = (aitString*)vdd.dataAddress();	str->copy(ts->value);	vdd.setStatSevr(ts->status,ts->severity);	return dd;}/* **************************** Emacs Editing Sequences ***************** *//* Local Variables: *//* tab-width: 4 *//* c-basic-offset: 4 *//* c-comment-only-line-offset: 0 *//* c-file-offsets: ((substatement-open . 0) (label . 0)) *//* End: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -