Ejemplo n.º 1
0
RTDB_API PRTK_TAG PMC_API query_tag_f(
	PCTAG_NAME tag
	)
{
	RTK_CURSOR hNode;
	RTK_TAG * pTag;
	hNode = open_node(&tag->node);
	if(!hNode){
		return 0;
	}
	pTag = query_tag(hNode, &tag->sname);
	close_handle(hNode);
	return pTag;
}
Ejemplo n.º 2
0
/*
功能:将TAG_VALUE实时值写入设备。
参数:
      name  待写入实时值对应的   组名.标签名
	  value 待写入的实时值
返回:即设备驱动导出函数write_device()的返回值
*/
IO_API __bool PMC_API io_write_device(
	PCSHORT_TAG_NAME name, 
	PCTAG_VALUE value
	)
{
	__bool retval = __false;
    
	//1 锁定
	if(!lock_rtdb(__false, 100)){
		return __false;
	}
	//2 找到本地节点中的指定标签点的RTK_TAG,其中存有该标签点对应的设备信息
	PRTK_TAG p = query_tag(HNODE_LOCAL_MACHINE, name);
	
	//3 将单点单实时值写入设备
	if(p && !(p->d.Value.Flags & TF_ReadOnly)){
	#if 0
		{
			char valbuf[32];
			if(get_value_type(p->s.Flags) == dt_real4){
				sprintf(valbuf, "%f", value->fltValue);
			}else{
				sprintf(valbuf, "%s", value->iValue? "On" : "Off");
			}
			utils_debug(
				"WriteDevice(%s.%s)=%s\n", 
				(char *)CGroupName(name->group),
				(char *)CTagName(name->tag),
				valbuf
				);
		}
	#endif
		//调用设备驱动导出函数,将单点单实时值写入设备
		retval = _writeDevice(p, value);
	}
	//4 解锁
	unlock_rtdb();

	return retval;
}
Ejemplo n.º 3
0
/*
功能:将pmc_value_t实时值写入设备
参数:
      name    待写入实时值对应的   组名.标签名
	  value   待写入的实时值
返回:即设备驱动导出函数write_device()的返回值
*/
IO_API __bool PMC_API io_write_device_ex(
	PCSHORT_TAG_NAME name, 
	PCpmc_value_t value
	)
{
	pmc_value_t value2;
	__bool retval = __false;

	if(!lock_rtdb(__false, 100)){
		return __false;
	}
	PRTK_TAG p = query_tag(HNODE_LOCAL_MACHINE, name);
	if(p && !(p->d.Value.Flags & TF_ReadOnly)){
		ZeroMemory(&value2, sizeof(value2));
		set_value_type(value2.Flags, get_value_type(p->s.Flags));
		if(pmc_type_cast(value, &value2)){
			retval = _writeDevice(p, &value2.Value);
		}
	}
	unlock_rtdb();

	return retval;
}
Ejemplo n.º 4
0
CExpression::arbore CExpression::identificator()
{
	int poz;
	arbore nod = NULL,nod2 = NULL;
	arbore result = NULL;
	TAG_NAME tn;

	poz=pozitie;
	SkipSpaces();

	if (m_definitie[pozitie]=='\0') result	= NULL;

	if (isdigit(m_definitie[pozitie])){  // Este numar ?
		while  ((isdigit(m_definitie[pozitie]) || (m_definitie[pozitie]=='.'))){
			pozitie++;
		}
		nod = new NOD;
		nod->left = NULL; 
		nod->right = NULL;
		nod->operatie = '@';
		nod->valoare = atof(m_definitie.Mid(poz,pozitie-poz));
		result = nod;
	}else if (_is_valid_id_char(m_definitie[pozitie])){  // Am i an identifier ?
		//if (isalpha(m_definitie[pozitie]) ){	// Am i an identifier ?
		//while  (isalnum(m_definitie[pozitie])) 
		LPCSTR str = m_definitie;
		while  (_is_valid_id_char(str[pozitie])) {
			pozitie++;
		}
		
		CString id = m_definitie.Mid(poz,pozitie-poz);
		CString nid = id;
		id.MakeUpper();
		
		if (id =="SIN"){	 // Functia sinus CString
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=150;
			SkipSpaces();
			return nod;
		}else if (id =="COS")	  // Functia sinus CString
		{
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=151;
			SkipSpaces();
			return nod;
		}else if (id =="EXP") 	// Functia sinus CString
		{
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=152;
			SkipSpaces();
			return nod;
		}else if (id =="SQRT")		// Functia sinus CString
		{
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=153;
			SkipSpaces();
			return	nod;
		}else if (id =="LOG") 	// Functia sinus CString
		{
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=154;
			SkipSpaces();
			return nod;
		}else if (id =="TG")		// Functia sinus CString
		{
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=155;
			SkipSpaces();
			return nod;
		}else if (id =="CTG"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=156;
			SkipSpaces();
			return nod;
		}else if (id =="ASIN"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=157;
			SkipSpaces();
			return nod;
		}else if (id =="ACOS"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=158;
			SkipSpaces();
			return nod;
		}else if (id =="ATG"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=159;
			SkipSpaces();
			return nod;
		}else if (id =="$YEAR"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=160;
			SkipSpaces();
			return nod;
		}else if (id =="$MONTH"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=161;
			SkipSpaces();
			return nod;
		}else if (id =="$DAY"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=162;
			SkipSpaces();
			return nod;
		}else if (id =="$HOUR"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=163;
			SkipSpaces();
			return nod;
		}else if (id =="$MINUTE"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=164;
			SkipSpaces();
			return nod;
		}else if (id =="$SECOND"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=165;
			SkipSpaces();
			return nod;
		}else if (id =="MAX"){
			SkipSpaces();
			if(m_definitie[pozitie] != '('){
				return NULL;
			}
			pozitie++;
			nod2 = factor();
			// skip ';'
			SkipSpaces();
			if(m_definitie[pozitie] != ';'){
				return NULL;
			}
			pozitie++;
			arbore nod3 = factor();
			if(!nod3){
				return NULL;
			}
			SkipSpaces();
			if(m_definitie[pozitie] != ')'){
				return NULL;
			};
			pozitie++;
			nod = new NOD;
			nod->left = nod2;
			nod->right = nod3;
			nod->operatie=166;
			SkipSpaces();
			return nod;
		}else if (id =="MIN"){
			SkipSpaces();
			if(m_definitie[pozitie] != '('){
				return NULL;
			}
			pozitie++;
			nod2 = factor();
			// skip ';'
			SkipSpaces();
			if(m_definitie[pozitie] != ';'){
				return NULL;
			}
			pozitie++;
			arbore nod3 = factor();
			if(!nod3){
				return NULL;
			}
			SkipSpaces();
			if(m_definitie[pozitie] != ')'){
				return NULL;
			}
			pozitie++;
			nod = new NOD;
			nod->left = nod2;
			nod->right = nod3;
			nod->operatie=167;
			SkipSpaces();
			return nod;
		}else if (id =="RANDOM"){
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=168;
			SkipSpaces();
			return nod;
		}else if (id == "$NOW"){
			nod2 = factor();
			nod = new NOD;
			nod->left = NULL;
			nod->right=NULL;
			nod->operatie=169;
			SkipSpaces();
			return nod;
		}else if (id == "LASTUPDATE"){
			/* added by jackie, 2004/2/26 */
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=170;
			SkipSpaces();
			return nod;
		}else if(id == "SPAN"){
			/* added by jackie, 2004/2/26 */
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=172;
			SkipSpaces();
			return nod;
		}else if(id == "ABS"){
			// added by chenj, 2008-5-22
			nod2 = factor();
			nod = new NOD;
			nod->left = nod2;
			nod->right=NULL;
			nod->operatie=173;
			SkipSpaces();
			return nod;
		}

		// is not a keyward, check if it's a database tag
		if(tagname_by_text(&tn, (char*)(LPCTSTR)id) ){
			nod = new NOD;
			nod -> left = NULL;
			nod -> right = NULL;
			nod -> operatie = 171;
			nod -> pvObj = query_tag(HNODE_LOCAL_MACHINE, &tn.sname);
			SkipSpaces();
			result = nod;
		}else{
			result = NULL;
		}
	}
	SkipSpaces();
	return result;		  
}