发表于:2016/10/21 11:33:39
#0楼
//macro_UpData
//更新配方内容
//本地配方:RW100开始每25个字为一个记录共限制记录1000组配方
//远程配方:将当有使用配方数据打包由PLC发送到远程服务器
// 0x47 0x31 [2个字节数据长度][12个字节ParamaterName] [n字节]
macro_command main()
bool BON = 1
bool BOFF =0
bool DONE
char PNM[12]
char CMD[48]
short BUSY
short HDB[25]
short Paramater_ID
short NLGT
short page
short LDB[25]
short LDB_LGT = 25
short LDB_NUM = 1000
short LDB_OFFS = 100
short LDB_END
short DPTR
short DPTR2
short DB_SEL
LDB_END = LDB_OFFS + (LDB_LGT * LDB_NUM)
SetData(BOFF, "Local HMI", "Excule_UpData", 1)
GetData(DB_SEL, "Siemens S7-200 SMART PPI", "PC_LOCAL_DB", 1)
GetData(BUSY, "Siemens S7-200 SMART PPI", "PC_LINK_BUSY", 1)
GetData(Paramater_ID, "Siemens S7-200 SMART PPI", "USER_PARAMATER", 1)
////////////////////
GetData(PNM[0], "Local HMI", "KEY_ModeName", 12)
NLGT = StringLength(PNM[0])
SetData(NLGT, "Local HMI", "KEY_ModeNameLenght", 1)
//////////////////////
GetData(HDB[0], "Local HMI", "KEY_ModeNameLenght", 1)
GetData(HDB[1], "Local HMI", "KEY_ModeName", 6)
GetData(HDB[7], "Siemens S7-200 SMART PPI", "show_temperature_set", 1)
if(Paramater_ID == 0)then
GetData(HDB[8], "Siemens S7-200 SMART PPI", "up_once_pressure", 7)
else
GetData(HDB[8], "Siemens S7-200 SMART PPI", "up_once_pressure", 7)
end if
///////////////////////
if( NLGT > 0 and NLGT < 12)then
if(DB_SEL == 0)then
page = 78
DPTR = LDB_OFFS
DONE = BOFF
while((DONE == BOFF) and (DPTR < LDB_END))
GetData(LDB[0], "Local HMI", RW, DPTR, 25)
DONE = (HDB[0]==LDB[0])and(HDB[1]==LDB[1])and(HDB[2]==LDB[2])and(HDB[3]==LDB[3])and(HDB[4]==LDB[4])and(HDB[5]==LDB[5])and(HDB[6]==LDB[6])
if(DONE == BON)then
SetData(HDB[0], "Local HMI", RW, DPTR, 25)
else
DPTR = DPTR + LDB_LGT
end if
wend
if(DONE == BOFF)then
DPTR = LDB_END - LDB_LGT
DPTR2 = DPTR - LDB_LGT
while(DPTR > LDB_OFFS)and(DPTR2 >= LDB_OFFS)
GetData(LDB[0], "Local HMI", RW, DPTR2, 25)
SetData(LDB[0], "Local HMI", RW, DPTR, 25)
DPTR = DPTR2
DPTR2 = DPTR - LDB_LGT
wend
SetData(HDB[0], "Local HMI", RW, DPTR, 25)
end if
else
if(BUSY)then
page = 123
else
BUSY = 1
page = 122
CMD[0] = 47
CMD[1] = 0x31
HEX2ASCII(NLGT, CMD[2], 2)
GetData(CMD[4], "Local HMI", "KEY_ModeName", 12)
HEX2ASCII(HDB[7], CMD[16], 4)
HEX2ASCII(HDB[8], CMD[20], 4)
HEX2ASCII(HDB[9], CMD[24], 4)
HEX2ASCII(HDB[10], CMD[28], 4)
HEX2ASCII(HDB[11], CMD[32], 4)
HEX2ASCII(HDB[12], CMD[36], 4)
HEX2ASCII(HDB[13], CMD[40], 4)
HEX2ASCII(HDB[14], CMD[44], 4)
SetData(CMD[0], "Siemens S7-200 SMART PPI", "PC_CMD", 48)
SetData(BUSY, "Siemens S7-200 SMART PPI", "PC_LINK_BUSY", 1)
end if
end if
else
page = 123
end if
SetData(page, "Local HMI", "SW_Window", 1)
end macro_command
//更新配方内容
//本地配方:RW100开始每25个字为一个记录共限制记录1000组配方
//远程配方:将当有使用配方数据打包由PLC发送到远程服务器
// 0x47 0x31 [2个字节数据长度][12个字节ParamaterName] [n字节]
macro_command main()
bool BON = 1
bool BOFF =0
bool DONE
char PNM[12]
char CMD[48]
short BUSY
short HDB[25]
short Paramater_ID
short NLGT
short page
short LDB[25]
short LDB_LGT = 25
short LDB_NUM = 1000
short LDB_OFFS = 100
short LDB_END
short DPTR
short DPTR2
short DB_SEL
LDB_END = LDB_OFFS + (LDB_LGT * LDB_NUM)
SetData(BOFF, "Local HMI", "Excule_UpData", 1)
GetData(DB_SEL, "Siemens S7-200 SMART PPI", "PC_LOCAL_DB", 1)
GetData(BUSY, "Siemens S7-200 SMART PPI", "PC_LINK_BUSY", 1)
GetData(Paramater_ID, "Siemens S7-200 SMART PPI", "USER_PARAMATER", 1)
////////////////////
GetData(PNM[0], "Local HMI", "KEY_ModeName", 12)
NLGT = StringLength(PNM[0])
SetData(NLGT, "Local HMI", "KEY_ModeNameLenght", 1)
//////////////////////
GetData(HDB[0], "Local HMI", "KEY_ModeNameLenght", 1)
GetData(HDB[1], "Local HMI", "KEY_ModeName", 6)
GetData(HDB[7], "Siemens S7-200 SMART PPI", "show_temperature_set", 1)
if(Paramater_ID == 0)then
GetData(HDB[8], "Siemens S7-200 SMART PPI", "up_once_pressure", 7)
else
GetData(HDB[8], "Siemens S7-200 SMART PPI", "up_once_pressure", 7)
end if
///////////////////////
if( NLGT > 0 and NLGT < 12)then
if(DB_SEL == 0)then
page = 78
DPTR = LDB_OFFS
DONE = BOFF
while((DONE == BOFF) and (DPTR < LDB_END))
GetData(LDB[0], "Local HMI", RW, DPTR, 25)
DONE = (HDB[0]==LDB[0])and(HDB[1]==LDB[1])and(HDB[2]==LDB[2])and(HDB[3]==LDB[3])and(HDB[4]==LDB[4])and(HDB[5]==LDB[5])and(HDB[6]==LDB[6])
if(DONE == BON)then
SetData(HDB[0], "Local HMI", RW, DPTR, 25)
else
DPTR = DPTR + LDB_LGT
end if
wend
if(DONE == BOFF)then
DPTR = LDB_END - LDB_LGT
DPTR2 = DPTR - LDB_LGT
while(DPTR > LDB_OFFS)and(DPTR2 >= LDB_OFFS)
GetData(LDB[0], "Local HMI", RW, DPTR2, 25)
SetData(LDB[0], "Local HMI", RW, DPTR, 25)
DPTR = DPTR2
DPTR2 = DPTR - LDB_LGT
wend
SetData(HDB[0], "Local HMI", RW, DPTR, 25)
end if
else
if(BUSY)then
page = 123
else
BUSY = 1
page = 122
CMD[0] = 47
CMD[1] = 0x31
HEX2ASCII(NLGT, CMD[2], 2)
GetData(CMD[4], "Local HMI", "KEY_ModeName", 12)
HEX2ASCII(HDB[7], CMD[16], 4)
HEX2ASCII(HDB[8], CMD[20], 4)
HEX2ASCII(HDB[9], CMD[24], 4)
HEX2ASCII(HDB[10], CMD[28], 4)
HEX2ASCII(HDB[11], CMD[32], 4)
HEX2ASCII(HDB[12], CMD[36], 4)
HEX2ASCII(HDB[13], CMD[40], 4)
HEX2ASCII(HDB[14], CMD[44], 4)
SetData(CMD[0], "Siemens S7-200 SMART PPI", "PC_CMD", 48)
SetData(BUSY, "Siemens S7-200 SMART PPI", "PC_LINK_BUSY", 1)
end if
end if
else
page = 123
end if
SetData(page, "Local HMI", "SW_Window", 1)
end macro_command