bool AddOK,AddNG,ON=true
short AddDatOK,AddDatNG
short Month,Day,DateStamp
short hour
short zero = 0
int int_zero = 0
int DayShift_ProductOKCount //白班OK总计数
int DayShift_ProductNGCount //白班NG总计数
int NightShift_ProductOKCount //夜班OK总计数
int NightShift_ProductNGCount //夜班NG总计数
float DayPassRate //白班良率
float NightPassRate //白班良率
int Recipe_OK,Recipe_NG//配方内的NG/OK数量
short Current_Recipe
char date[6] //date of string
char str_zero[1] = "0" //字符'0'
int str_len //字符长度
//*******************************************配方系统变量的定义**********************
short Recipe_Selection //选中配方的编号
short Recipe_Count //配方大小
short Recipe_Creat = 1 //新增配方记录
short Recipe_Update = 2 //更新所选配方记录
short Recipe_Delete = 3 //删除所选配方记录
//*******************************************配方系统变量的定义**********************
//*******************************************获取HMI时间日期**********************
GetData(Month, "Local HMI", LW, 9021, 1) //HMI_月
GetData(Day, "Local HMI", LW, 9020, 1) //HMI_日
GetData(hour, "Local HMI", LW, 9019, 1) //HMI_时
//*******************************************获取HMI时间日期**********************
GetData(DateStamp, "Local HMI", RW, 1000, 1) //时间戳
GetData(Recipe_Count, "Local HMI", RECIPE, "ProduceCount.Count")
if Recipe_Count > 0 then
Current_Recipe = Recipe_Count - 1
else
Current_Recipe = Recipe_Count
end if
GetData(AddOK, "CODESYS V3 (Ethernet)", "Application.Important_GVL.AddOK", 1)
GetData(AddNG, "CODESYS V3 (Ethernet)", "Application.Important_GVL.AddNG", 1)
GetData(AddDatOK, "CODESYS V3 (Ethernet)", "Application.Important_GVL.AddDatOK", 1)
//********************************************************OK开始累加****************************************
if AddOK and AddDatOK >= 0 then
//*****************************数据 到达上限后删除第一组数据*************************
if DateStamp <> Day and Recipe_Count >= 31 then
SetData(zero, "Local HMI", RECIPE, "ProduceCount.Selection") //选中第一个数据
SetData(Recipe_Delete, "Local HMI", RECIPE, "ProduceCount.Command") //删除选中数据
DELAY(100)
end if
//GetData(AddDatOK, "CODESYS V3 (Ethernet)", "Application.Important_GVL.AddDatOK", 1)
//*****************************根据时间修改当前数据*************************
if DateStamp == Day and Recipe_Count > 0 then
SetData(Current_Recipe, "Local HMI", RECIPE, "ProduceCount.Selection")
select case hour
case 0
GetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK1")
Recipe_OK = Recipe_OK + AddDatOK
SetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK1")
break
case 1
GetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK2")
Recipe_OK = Recipe_OK + AddDatOK
SetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK2")
break
case 2
GetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK3")
Recipe_OK = Recipe_OK + AddDatOK
SetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK3")
break
case 3
GetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK4")
Recipe_OK = Recipe_OK + AddDatOK
SetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK4")
break
case 4
GetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK5")
Recipe_OK = Recipe_OK + AddDatOK
SetData(Recipe_OK, "Local HMI", RECIPE, "ProduceCount.OK5")
break