АЛМ писал(а): И еще в макросе используйте проверку на ошибку получения или передачи.
sub unsigned short count_seconds (unsigned short cntr_sec, unsigned int in_addr)
unsigned short cntr_seconds
unsigned int address, ledad
bool in_state = false
cntr_seconds = cntr_sec
address = in_addr
GetData(in_state, "MODBUS TCP/IP (Zero-based Addressing)", 6x_Bit, address, 1)
if in_state == true then
cntr_seconds = cntr_seconds + 1
end if
return cntr_seconds
end sub
sub unsigned short count_hours(unsigned short cnt_seconds, unsigned short cntr_hours)
unsigned short motohours
if cnt_seconds >= 3600 then
// if cnt_seconds >= 10 then//3600 then
motohours = cntr_hours + 1
end if
return motohours
end sub
GetData(read_seconds, "Local HMI", "DP1_seconds", 1)
GetData(read_hours, "Local HMI", "DP1_hours", 1)
addr = 200005
cntr_seconds = count_seconds(read_seconds, addr)
cntr_hours = count_hours(cntr_seconds, read_hours)
if cntr_hours > read_hours then
SetData(cntr_hours, "Local HMI", "DP1_hours", 1)
cntr_seconds = 0
end if
SetData(cntr_seconds, "Local HMI", "DP1_seconds", 1)
GetData(read_seconds, "Local HMI", "DP2_seconds", 1)
GetData(read_hours, "Local HMI", "DP2_hours", 1)
addr = 200006
cntr_seconds = count_seconds(read_seconds, addr)
cntr_hours = count_hours(cntr_seconds, read_hours)
if cntr_hours > read_hours then
SetData(cntr_hours, "Local HMI", "DP2_hours", 1)
cntr_seconds = 0
end if
SetData(cntr_seconds, "Local HMI", "DP2_seconds", 1)
mcleon писал(а):Пытаюсь реализовать подсчет моточасов.
Для хранения часов использую RW.
DEL
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 7