You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

90 lines
2.3 KiB

FUNCTION_BLOCK BS_DevScan
VAR_EXTERNAL
END_VAR
VAR_INPUT
Dev_Scan_Hex :DWORD; (*线*)
Dev_Array :ARRAY[0..31] of byte;(**)
END_VAR
VAR_OUTPUT
Dev_Status :DWORD; (*线*)
Dev_Ratio :REAL; (*线*)
Dev_Ready :BOOL; (*0为存在不运行模块1为全部正常运行*)
Dev_Total :INT; (**)
Dev_Error :INT; (**)
HeartVavle :int;
END_VAR
VAR
i :UINT;
Dev_Scan_temp :DWORD;
Dev_Error_Flag :BOOL;
Dev_Status_temp :DWORD;
SHR_D :SHR_DWORD;
SHR_L :SHL_DWORD;
ton1 :ton;
END_VAR
(*
20190905
1.0
线线
*)
(**)
Dev_Error_Flag := 0;
Dev_Status := 0;
Dev_Total := 0;
Dev_Error := 0;
for i:= 0 to 31 by 1 do
Dev_Scan_temp := 0;
SHR_D(EN :=1 , IN := Dev_Scan_Hex , N := i | Dev_Scan_temp:= OUT);
(*i1地址位与16#1进行AND比较如果为1i线*)
if (Dev_Scan_temp and 16#1) = 1 then
Dev_Total := Dev_Total+1;
(*i地址位判断值是否为16#4*)
if Dev_Array[i] = 16#4 then
Dev_Status_temp := 1;
(*1地址位左移至i位ORi*)
SHR_L(EN :=1 , IN := Dev_Status_temp, N := i | Dev_Status_temp := OUT);
Dev_Status :=Dev_Status_temp or Dev_Status ;
else
(**)
Dev_Error_Flag := 1;
Dev_Error:= Dev_Error+1;
end_if;
end_if;
end_for;
if Dev_Scan_Hex<>0 then
(**)
Dev_Ready := not Dev_Error_Flag;
end_if;
if Dev_Total<>0 then
(*线*)
Dev_Ratio := 1.0-INT_TO_REAL(Dev_Error)/INT_TO_REAL(Dev_Total);
end_if;
ton1(pt:=t#2s);
ton1.in:=not ton1.q;
if ton1.q=1 then
HeartVavle :=HeartVavle+1;
end_if;
if HeartVavle =99 then
HeartVavle:=0;
end_if;
END_FUNCTION_BLOCK