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

📄 103.c

📁 标准103规约的说明和在mc68332开发环境下的详细程序
💻 C
📖 第 1 页 / 共 4 页
字号:
			*apack++ =*pt++;
			i++;
		}
		j++;
	}
	C103_Send( id, sbuf, i );
}
//
void send_liangcheng(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
	BYTE j;
	BYTE l;
	BYTE lb;
	BYTE num;
	
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2a;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	j=1;//条目号
	k =*pt;
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =ginh;
		*apack++ =j;
		*apack++ =0x03;
		*apack++ =*pt++;
		i =i+4;
		l =*pt;
		lb = l;
		*apack++ =*pt++;
		i++;
		num =*pt;//数目
		*apack++ =*pt++;
		i++;
		while(num > 0,num--)
		{
			l = lb;
			while (l>0,l--)
			{
				*apack++ =*pt++;
				i++;
			}
		}
		j++;
	}
	C103_Send( id, sbuf, i );
}
//
void send_lianggang(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
	BYTE j;
	BYTE l;
	BYTE lb;
	BYTE num;
	
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2a;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	j=1;//条目号
	k =*pt;
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =ginh;
		*apack++ =j;
		*apack++ =0x09;
		*apack++ =*pt++;
		i =i+4;
		l =*pt;
		lb = l;
		*apack++ =*pt++;
		i++;
		num =*pt;//数目
		*apack++ =*pt++;
		i++;
		while(num > 0,num--)
		{
			l = lb;
			while (l>0,l--)
			{
				*apack++ =*pt++;
				i++;
			}
		}
		j++;
	}
	C103_Send( id, sbuf, i );
}
//
void send_jingdu(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
	BYTE j;
	BYTE l;
	BYTE lb;
	BYTE num;
	
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2a;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	j=1;//条目号
	k =*pt;
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =ginh;
		*apack++ =j;
		*apack++ =0x05;
		*apack++ =*pt++;
		i =i+4;
		l =*pt;
		lb = l;
		*apack++ =*pt++;
		i++;
		num =*pt;//数目
		*apack++ =*pt++;
		i++;
		while(num > 0,num--)
		{
			l = lb;
			while (l>0,l--)
			{
				*apack++ =*pt++;
				i++;
			}
		}
		j++;
	}
	C103_Send( id, sbuf, i );
}
//
void send_quesheng(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
	BYTE j;
	BYTE l;
	BYTE lb;
	BYTE num;
	
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2a;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	j=1;//条目号
	k =*pt;
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =ginh;
		*apack++ =j;
		*apack++ =0x02;
		*apack++ =*pt++;
		i =i+4;
		l =*pt;
		lb = l;
		*apack++ =*pt++;
		i++;
		num =*pt;//数目
		*apack++ =*pt++;
		i++;
		while(num > 0,num--)
		{
			l = lb;
			while (l>0,l--)
			{
				*apack++ =*pt++;
				i++;
			}
		}
		j++;
	}
	C103_Send( id, sbuf, i );
}
//
void send_yinzi(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
	BYTE j;
	BYTE l;
	
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2a;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	j=1;//条目号
	k =*pt;
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =ginh;
		*apack++ =j;
		*apack++ =0x06;
		*apack++ =*pt++;
		i =i+4;
		l =*pt;
		*apack++ =*pt++;
		i++;
		*apack++ =*pt++;
		i++;
		while (l>0,l--)
		{
			*apack++ =*pt++;
			i++;
		}
		j++;
	}
	C103_Send( id, sbuf, i );
}
//
void send_data(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
	BYTE j;
	BYTE l;
	
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2a;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	j=1;//条目号
	k =*pt;
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =ginh;
		*apack++ =j;
		*apack++ =0x01;
		*apack++ =*pt++;
		i =i+4;
		l =*pt;
		*apack++ =*pt++;
		i++;
		*apack++ =*pt++;
		i++;
		while (l>0,l--)
		{
			*apack++ =*pt++;
			i++;
		}
		j++;
	}
	C103_Send( id, sbuf, i );
}
//
void send_yxkdata(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
	BYTE j;
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2a;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	j=1;//条目号
	k =*pt;
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =ginh;
		*apack++ =j;
		*apack++ =0x01;
		*apack++ =0x09;//os8ascii
		*apack++ =0x01;
		*apack++ =0x01;
		*apack++ =*pt++;
		i =i+7;
		j++;
	}
		
	C103_Send( id, sbuf, i );
}
//
void send_runquhao(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii,BYTE cot)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
	BYTE k;
    pt =buff103;
	apack =sbuf;
	i=7;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =cot;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	
	*apack++ =0x01;//数目
	i++;
	*apack++ =ginh;
	i++;
	*apack++ =0x03;
	i++;
	*apack++ =0x01;
	i++;
	*apack++ =*pt++;//数据类型
	i++;
	*apack++ =*pt++;//数据宽度
	i++;
	k = *pt;//数目
	*apack++ =*pt++;//数目
	i++;
	while(k > 0,k--)
	{
		*apack++ =*pt++;
		i++;
	}
		
	C103_Send( id, sbuf, i );
}
//
void send05(BYTE *sbuf,WORD id,BYTE commaddress,BYTE *buff103)
{
	BYTE *s;
	BYTE *cpAck;
	int l;
	WORD i;
	Get103_changname(buff103,commaddress);
	s =buff103;
	cpAck =sbuf;
	*cpAck++ =0x05;  //type
	*cpAck++ =0x81;  //sq
	*cpAck++ =0x03;  //cot
	*cpAck++ =commaddress; //address
	*cpAck++ =0xff;	 //fun
	*cpAck++ =0x02;  //inf
	*cpAck++ =0x03;  //cql
	i =7;
	l =8;	
	while(l > 0)
	{
		*cpAck++=*s++;
		l--;
		i++;
	}
	Get103_biaoshi(buff103,commaddress);
	s =buff103;
	*cpAck++=*s++;
	i++;
	Get103_bianhao(buff103,commaddress);
	s =buff103;
	*cpAck++=*s++;
	i++;
	Get103_banben(buff103,commaddress);
	s =buff103;
	*cpAck++=*s++;
	i++;
	*cpAck++=*s++;
	i++;
		
    C103_Send( id, sbuf, i );
}
//	
void send0a(BYTE *sbuf,WORD id,BYTE con,BYTE commaddress,BYTE fun,BYTE scn,BYTE *buff103)
{
	//通用报文10,回答总查询
	//L=遥信的数目
	//J=遥信组号下的条目号
	//遥信可以时单点也可以时双点信息
    BYTE l;
	BYTE j;
	BYTE k;
	BYTE num;
	BYTE *s;
	BYTE *cpAck;
	WORD i;//报文总长度
	cpAck =sbuf;
	i =7;
	*cpAck++ =10;
	*cpAck++ =0x81;
	*cpAck++ =con;
	*cpAck++ =commaddress;
	*cpAck++ =fun;
	*cpAck++ =241;
	*cpAck++ =scn;//0;
	Get103_yxdata(buff103,commaddress);
	s =buff103;
	k =*s;   //
	l =*s++;//遥信的数目
	j=1;   //遥信的起始条目号
	*cpAck++ =40;//遥信的数目+遥测的数目 
	i++;
	while(l !=0)   //32 个遥信
	{
	*cpAck++ =0x08;
	*cpAck++ =j;
	*cpAck++ =1;
	*cpAck++ =9;
	*cpAck++ =1;
	*cpAck++ =1;
	*cpAck++ =*s++;//合或分位
	l--;
	j++;
	i =i+7;
	}
//以下是遥测
    Get103_yuandongdata( buff103,commaddress);
	s =buff103;
	l =*s++;   //遥测的数目
	k =k+l;    //该桢报文的条目数
	num = 1;
	while(l !=0)
	{
	*cpAck++ =0x07;//远动测量的组号
	*cpAck++ =num;//*s++;//保护测量的条目号
	*cpAck++ =0x01;//保护测量的描述类别1=实际值;
	*cpAck++ =*s++;//保护测量的数据类型7=R32。23;
	j =*s;         //保护测量的数据宽度4=4字节
	*cpAck++ =*s++;//保护测量的数据宽度4=4字节;
	*cpAck++ =*s++;//保护测量的数目1=表明该条目下只有一个数据;
	i =i+6;
		while(j !=0,j--)
		{
			*cpAck++ =*s++;//保护测量的数据
			i++;
		}
		num++;
	l--;
	}
//以下是分接头
    Get103_gradingdata( buff103,commaddress);
	s =buff103;
	l =*s++;   //分接头的数目
	k =k+l;    //该桢报文的条目数
	num = 1;
	while(l !=0)
	{
	*cpAck++ =0x0c;//分接头的组号
	*cpAck++ =num;//*s++;//分接头的条目号
	*cpAck++ =0x01;//分接头的描述类别1=实际值;
	*cpAck++ =*s++;//分接头的数据类型25=BCD,26=HEX
	j =*s;         //分接头的数据宽度
	*cpAck++ =*s++;//分接头的数据宽度
	*cpAck++ =*s++;//分接头的数目1=表明该条目下只有一个数据;
	i =i+6;
		while(j !=0,j--)
		{
			*cpAck++ =*s++;//分接头的数据
			i++;
		}
		num++;
	l--;
	}
	cpAck =sbuf+7;
	*cpAck =k;    //本次传送的总条目数
	//
	C103_Send( id, sbuf, i );//
}			
//
//************************保护远方控制分头有关函数*********************/////
BOOL Set103_selectft(BYTE* buff103,BYTE commaddress)       //远方控制分头
{
	return true;
}
                                                           //数据格式为:条目号,参数(1==退,2==投)
                                                          //有返回
                                                         //
BOOL Set103_controlft(BYTE* buff103,BYTE commaddress)       //远方控制分头
{
	return true;
}                                                          //数据格式为:条目号,参数(1==退,2==投)                                         
                                                          //有返回
                                                          //
//无效数据响应
void send_error(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii)
{
	BYTE *pt;
	BYTE *apack;
	WORD i;
		
    pt =buff103;
	apack =sbuf;
	i=10;
	*apack++ =10;
	*apack++ =0x81;
	*apack++ =0x2b;
	*apack++ =commaddress;
	*apack++ =0xfe;
	*apack++ =0xf1;
	*apack++ =rii;
	*apack++ =0x01;
	*apack++ =ginh;
	*apack++ =0x00;
	C103_Send( id, sbuf, i );
}
//
void Send_current_table(BYTE ginh,BYTE *buff103,BYTE *sbuf,WORD id,BYTE commaddress,BYTE rii,WORD struct_number)
{
	WORD frame_leng;
	BYTE *pt;
	BYTE *apack;
	BYTE i,j;
	pt = buff103;
	apack = sbuf;
	*apack++ = 0x0a;
	*apack++ = 0x81;
	*apack++ = 42;
	*apack++ = commaddress;
	*apack++ = 0xfe;
	*apack++ = 0xf4;
	*apack++ = rii;
	*apack++ = 0x01;
	*apack++ = 0x20;
	*apack++ = 0x01;
	*apack++ = 0x01;
	*apack++ = 23;//struct
	frame_leng = 12;
	while (struct_number > 0)
	{
		*apack++ = *pt++;
		frame_leng++;
		struct_number--;
	}
	C103_Send( id, sbuf, frame_leng );
}

⌨️ 快捷键说明

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