tangbingchen
级别: 探索解密
精华主题: 0
发帖数量: 93 个
工控威望: 164 点
下载积分: 2586 分
在线时间: 27(小时)
注册时间: 2018-07-10
最后登录: 2024-10-22
查看tangbingchen的 主题 / 回贴
楼主  发表于: 2022-08-14 12:52
*************************************************************************************)
REGION
    #A18 := #IN >= 32767;      
    #A19 := #IN <= -32768;    
    #A22 := #A18 OR #A19;
END_REGION

REGION
    #A17 := LIMIT(MN := 0, IN := #IN, MX := 27648);
    IF #A22 THEN
        #A17 := 0;
    END_IF;
END_REGION

REGION  
    IF #SQUA THEN
        #A17 := REAL_TO_INT((SQRT(INT_TO_REAL(#A17) / 27648.0)) * 27648.0);
    ELSE
        #A17 := #A17;
    END_IF;
END_REGION

REGION  
    IF NOT #SsrTy THEN
        #A15 := (INT_TO_REAL(#A17)) / 27648.0 * (#HiScl - #LoScl) + #LoScl;
    ELSE
        #A15 := (INT_TO_REAL(#A17)) / 10.0;
    END_IF;
    
    //revise
    #A16 := #A15 * #RvsMul + #RvsAdd;
    
    IF #A16 < #MinVal THEN
        #A11 := 0.0;
    ELSE
        #A11 := #A16;
    END_IF;
END_REGION

REGION  
    IF #HwSCW.HwSCW.%X0 THEN
        #A11 := #HwSCW.SimVal;
    ELSE
        #HwSCW.SimVal := #A11;
    END_IF;
    
    #Q := #A11;
    #HwSCW.Q := #A11;
    #HwSCW.Fill := (#A11 / #HiScl - #LoScl) * 100.0;
END_REGION

REGION
    REGION
        #A14 := 0;
        #A13[0] := 0.0;
        #A13[1] := 0.0;
        #A13[2] := 0.0;
        #A13[3] := 0.0;
        #A13[4] := 0.0;
        #A13[5] := 0.0;
        
        IF #AlmTy.%X5 THEN
            #A13[#A14] := #HwSCW.Setting.AHH;
            #A14 := #A14 + 1;
        END_IF;
        
        IF #AlmTy.%X4 THEN
            #A13[#A14] := #HwSCW.Setting.AH;
            #A14 := #A14 + 1;
        END_IF;
        
        IF #AlmTy.%X3 THEN
            #A13[#A14] := #HwSCW.Setting.SH;
            #A14 := #A14 + 1;
        END_IF;
        
        IF #AlmTy.%X2 THEN
            #A13[#A14] := #HwSCW.Setting.SL;
            #A14 := #A14 + 1;
        END_IF;
        
        IF #AlmTy.%X1 THEN
            #A13[#A14] := #HwSCW.Setting.AL;
            #A14 := #A14 + 1;
        END_IF;
        
        IF #AlmTy.%X0 THEN
            #A13[#A14] := #HwSCW.Setting.ALL;
            #A14 := #A14 + 1;
        END_IF;
        
        IF ABS(#A13[0]) >= ABS(#A13[1]) AND ABS(#A13[1]) >= ABS(#A13[2]) AND ABS(#A13[2]) >= ABS(#A13[3]) AND
            ABS(#A13[3]) >= ABS(#A13[4]) AND ABS(#A13[4]) >= ABS(#A13[5]) THEN
            #A23 := 0;
        ELSE
            #A23 := 1;
        END_IF;
    END_REGION
    
    IF #Polarity THEN           //0:positive/1:negative    
        //H
        #A12.%X1 := ABS(#A11) >= ABS(#HwSCW.Setting.AH) AND #AlmTy.%X4 AND #Feature.HAlmEnable;
        
        //SH
        #A12.%X2 := ABS(#A11) > ABS(#HwSCW.Setting.SH) AND #AlmTy.%X3 AND (NOT #A12.%X0) AND #Feature.HAlmEnable;
        
        //SL
        #A12.%X3 := ABS(#A11) < ABS(#HwSCW.Setting.SL) AND #AlmTy.%X2 AND (NOT #A12.%X5) AND #Feature.LAlmEnable;
        
        //L
        #A12.%X4 := ABS(#A11) <= ABS(#HwSCW.Setting.AL) AND #AlmTy.%X1 AND #Feature.LAlmEnable;
        
        //HH
        #A20 := ABS(#A11) >= ABS(#HwSCW.Setting.AHH) AND #AlmTy.%X5 AND #Feature.HAlmEnable;
        
        //LL
        #A21 := ABS(#A11) <= ABS(#HwSCW.Setting.ALL) AND #AlmTy.%X0 AND #Feature.LAlmEnable;
    ELSE
        //H
        #A12.%X1 := #A11 >= #HwSCW.Setting.AH AND #AlmTy.%X4 AND #Feature.HAlmEnable;
        
        //SH
        #A12.%X2 := #A11 > #HwSCW.Setting.SH AND #AlmTy.%X3 AND (NOT #A12.%X0) AND #Feature.HAlmEnable;
        
        //SL
        #A12.%X3 := #A11 < #HwSCW.Setting.SL AND #AlmTy.%X2 AND (NOT #A12.%X5) AND #Feature.LAlmEnable;
        
        //L
        #A12.%X4 := #A11 <= #HwSCW.Setting.AL AND #AlmTy.%X1 AND #Feature.LAlmEnable;
        
        //HH
        #A20 := #A11 >= #HwSCW.Setting.AHH AND #AlmTy.%X5 AND #Feature.HAlmEnable;
        
        //LL
        #A21 := #A11 <= #HwSCW.Setting.ALL AND #AlmTy.%X0 AND #Feature.LAlmEnable;
    END_IF;
    
    //HH
    #A01(IN := #A20,
            PT := #DlyTime.HH
    );
    
    IF #A01.Q THEN
        #A12.%X0 := 1;
    END_IF;
    
    //LL
    #A02(IN := #A21,
            PT := #DlyTime.LL
    );
    
    IF #A02.Q THEN
        #A12.%X5 := 1;
    END_IF;
    
    //Fault
    #A03(IN := #A22,
             PT := #DlyTime.Flt
    );
    
    IF #A03.Q THEN
        #A12.%X6 := 1;
    END_IF;
END_REGION

REGION
    IF (#A12.%X0 OR #A12.%X5 OR #A12.%X6) AND (#Ack OR #HwSCW.HwSCW.%X31) THEN
        #A10 := 1;
    END_IF;
    
    IF #A10 THEN
        IF NOT #A01.Q THEN
            #A12.%X0 := 0;
        END_IF;
        IF NOT #A02.Q THEN
            #A12.%X5 := 0;
        END_IF;
        IF NOT #A03.Q THEN
            #A12.%X6 := 0;
        END_IF;
    END_IF;
    IF #A12.%X0 = 0 AND #A12.%X5 = 0 AND #A12.%X6 = 0 THEN
        #A10 := 0;
    END_IF;
    
END_REGION

REGION  
    #QOK := (NOT #A12.%X0) AND (NOT #A12.%X1) AND (NOT #A12.%X4) AND (NOT #A12.%X5) AND (NOT #A12.%X6) AND (NOT #A23);
    
END_REGION

REGION
    #QAHH := #A12.%X0;
    #QAH := #A12.%X1;
    #QSH := #A12.%X2;
    #QSL := #A12.%X3;
    #QAL := #A12.%X4;
    #QALL := #A12.%X5;
    #QFlt := #A12.%X6;
    #QHiScl := #HiScl;
    #QLoScl := #LoScl;
    #HwSCW.QHiScl := #QHiScl;
    #HwSCW.QLoScl := #QLoScl;
END_REGION

REGION
    #A04(SIG := #QFlt AND NOT #HwSCW.HwSCW.%X15);
    #A05(SIG := #QAHH AND NOT #HwSCW.HwSCW.%X15);
    #A06(SIG := #QALL AND NOT #HwSCW.HwSCW.%X15);
    #A07(SIG := #QAH AND NOT #HwSCW.HwSCW.%X15);
    #A08(SIG := #QAL AND NOT #HwSCW.HwSCW.%X15);
    #A09(SIG := #A23 AND NOT #HwSCW.HwSCW.%X15);
END_REGION

REGION
    #HwSCW.HwSCW.%X1 := #HwSCW.HwSCW.%X7 AND #AlmTy.%X5;
    #HwSCW.HwSCW.%X2 := #HwSCW.HwSCW.%X7 AND #AlmTy.%X4;
    #HwSCW.HwSCW.%X3 := #HwSCW.HwSCW.%X7 AND #AlmTy.%X3;
    #HwSCW.HwSCW.%X4 := #HwSCW.HwSCW.%X7 AND #AlmTy.%X2;
    #HwSCW.HwSCW.%X5 := #HwSCW.HwSCW.%X7 AND #AlmTy.%X1;
    #HwSCW.HwSCW.%X6 := #HwSCW.HwSCW.%X7 AND #AlmTy.%X0;
    #HwSCW.HwSCW.%X16 := #A12.%X0;
    #HwSCW.HwSCW.%X17 := #A12.%X1;
    #HwSCW.HwSCW.%X18 := #A12.%X2;
    #HwSCW.HwSCW.%X19 := #A12.%X3;
    #HwSCW.HwSCW.%X20 := #A12.%X4;
    #HwSCW.HwSCW.%X21 := #A12.%X5;
    #HwSCW.HwSCW.%X22 := #A12.%X0 AND NOT #A10;
    #HwSCW.HwSCW.%X23 := #A12.%X5 AND NOT #A10;
    #HwSCW.HwSCW.%X24 := #A12.%X6;
    #HwSCW.HwSCW.%X25 := #A12.%X6 AND NOT #A10;
    #HwSCW.HwSCW.%X26 := #QOK;
    #HwSCW.HwSCW.%X8 := #AlmTy.%X5;    //AHH
    #HwSCW.HwSCW.%X9 := #AlmTy.%X4;    //AH
    #HwSCW.HwSCW.%X10 := #AlmTy.%X3;   //SH
    #HwSCW.HwSCW.%X11 := #AlmTy.%X2;   //SL
    #HwSCW.HwSCW.%X12 := #AlmTy.%X1;   //AL
    #HwSCW.HwSCW.%X13 := #AlmTy.%X0;   //ALL
    #HwSCW.HwSCW.%X28 := #A18;         //overflow    
    #HwSCW.HwSCW.%X29 := #A19;         //break line
    #HwSCW.HwSCW.%X30 := #A23;
    #HwSCW.HwSCW.%X31 := FALSE;        //Ack command from hmi
END_REGION
beni
级别: 工控侠客
精华主题: 0
发帖数量: 116 个
工控威望: 2125 点
下载积分: 50012 分
在线时间: 2637(小时)
注册时间: 2010-07-13
最后登录: 2024-11-22
查看beni的 主题 / 回贴
1楼  发表于: 2022-08-18 00:38
A12.%X0,A12.%X1,A12.%X4,A12.%X5,A12.%X6,A23