用自由协议直接发送,我这里做过炜煌的,讯普的没有做过。
unsigned char command0[3]={0x1B,0x63,0x00} //反向打印
unsigned char command1[3]={0x1B,0x36,0x02} //半角打印
unsigned short time[6],count,i
unsigned char line[50]
float temp[2]
bool tag
sub time_line()
OUTPORT(command0[0], "Free Protocol", 3) //设置半角字符
//一行数据
GetData(time[0], "Local HMI", LW, 9018, 2) //时间
DEC2ASCII(time[1], line[0], 2)
line[2]=0x3A
DEC2ASCII(time[0], line[3], 2)
line[5]=0x20
GetData(time[0], "Local HMI", RW, 2, 3)
DEC2ASCII(time[0], line[6], 3) //温度
line[9]=0xA1
line[10]=0xE6
line[11]=0x20
temp[0]=time[1]
temp[1]=time[2]
temp[0]=temp[0]/1000
temp[1]=temp[1]/1000
FLOAT2ASCII(temp[0], line[12], 5) //内室压力
line[17]=0x4D
line[18]=0x50
line[19]=0x41
line[20]=0x20
FLOAT2ASCII(temp[1], line[21], 5) //外室压力
line[22]=0x4D
line[23]=0x50
line[24]=0x41
line[25]=0x0a
OUTPORT(line[0], "Free Protocol", 26)
end sub
macro_command main()
unsigned char data[200]={0xBA,0xA3,0xC4,0xCF,0xD5,0xFD,0xB9,0xE2,0xD7,0xD4,0xB6,0xAF,0xBB,0xAF,0xBF,0xC6,0xBC,0xBC,0xD3,0xD0,0xCF,0xDE,0xB9,0xAB,0xCB,0xBE,0x0a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0xD5,0xE6,0xBF,0xD5,0xC2,0xF6,0xB6,0xAF,0xC3,0xF0,0xBE,0xFA,0xC6,0xF7,0x0a,0x0a}
//海南正光自动化科技有限公司
// 真空脉动灭菌器 (50字节)
//command[12]=0x3a//符号” : ”ASCII码
//command[13]=0x0a//执行换行
OUTPORT(command0[0], "Free Protocol", 3)
GetData(time[0], "Local HMI", LW, 9018, 6)//读取时间数据,设置打印出时间
DEC2ASCII(time[4], data[50], 4) //年
data[54]=0xc4
data[55]=0xea
DEC2ASCII(time[3], data[56], 2) //月
data[58]=0xd4
data[59]=0xc2
DEC2ASCII(time[2], data[60], 2) //日
data[62]=0xc8
data[63]=0xd5
data[64]=0x20
data[65]=0x20
data[66]=0xD0 //星期
data[67]=0xC7
data[68]=0xC6
data[69]=0xDA
if time[5]==0 then
data[70]=0xC8
data[71]=0xD5
else if time[5]==1 then
data[70]=0xD2
data[71]=0xBB
else if time[5]==2 then
data[70]=0xB6
data[71]=0xFE
else if time[5]==3 then
data[70]=0xC8
data[71]=0xFD
else if time[5]==4 then
data[70]=0xCB
data[71]=0xC4
else if time[5]==5 then
data[70]=0xCE
data[71]=0xE5
else if time[5]==6 then
data[70]=0xC1
data[71]=0xF9
end if
DEC2ASCII(time[1], data[72], 2)
data[74]=0xca
data[75]=0xb1
DEC2ASCII(time[0], data[76], 2)
data[78]=0xb7
data[79]=0xd6
data[80]=0x0a
data[81]=0x0a
data[82]=0x20
data[83]=0x20
data[84]=0x20
data[85]=0x20
data[86]=0x20
data[87]=0x20
data[88]=0x20
data[89]=0x20
data[90]=0xC9 //升温
data[91]=0xFD
data[92]=0xCE
data[93]=0xC2
data[94]=0x0a
data[95]=0x0a
data[96]=0x20
data[97]=0x20
data[98]=0xCE //温度
data[99]=0xC2
data[100]=0xB6
data[101]=0xC8
data[102]=0x20
data[103]=0x20
data[104]=0xC4 //内室压力
data[105]=0xDA
data[106]=0xCA
data[107]=0xD2
data[108]=0xD1
data[109]=0xB9
data[110]=0xC1
data[111]=0xA6
data[112]=0x20
data[113]=0x20
data[114]=0xCD //外室压力
data[115]=0xE2
data[116]=0xCA
data[117]=0xD2
data[118]=0xD1
data[119]=0xB9
data[120]=0xC1
data[121]=0xA6
data[122]=0x0a
data[123]=0x0a
OUTPORT(data[0], "Free Protocol", 124)
//升温
while 1
time_line()
for i=0 to 59 //延时一分钟
DELAY(1000)
next i
//GetData(tag, "Siemens S7-200", Q, 00, 1)
if tag==1 then
continue
else
break
end if
wend
end macro_command |