西门子 IO监控源程序 点击:368 | 回复:0



务实者

    
  • 精华:0帖
  • 求助:1帖
  • 帖子:8帖 | 27回
  • 年度积分:1
  • 历史总积分:380
  • 注册:2003年11月16日
发表于:2015-05-21 21:37:01
楼主

西门子批量监控IO 源程序

//另有全套西门子程序解决方案

//并有自动程序生成工具 减少你大型项目设计工时

//该程序架构常用在千万级项目中


//往上翻页按钮

IF #IO_com_hmi.page_Btn[1] THEN

    // #IO_com_hmi.page_Btn[1] := false;

    #IO_com_hmi.page_No := #IO_com_hmi.page_No - 1;

    //往下翻页按钮    

ELSIF #IO_com_hmi.page_Btn[2] THEN

    // #IO_com_hmi.page_Btn[2] := false;

    #IO_com_hmi.page_No := #IO_com_hmi.page_No + 1;

    

    //往上翻5页按钮

ELSIF #IO_com_hmi.page_Btn[3] THEN

   // #IO_com_hmi.page_Btn[3] := false;

    #IO_com_hmi.page_No := #IO_com_hmi.page_No - 5;

    //往下翻5页按钮

ELSIF #IO_com_hmi.page_Btn[4] THEN

   // #IO_com_hmi.page_Btn[4] := false;

    #IO_com_hmi.page_No := #IO_com_hmi.page_No + 5;

ELSIF   #IO_com_hmi.page_Btn[5] THEN

    IF #IO_com_hmi.IO_Type = 0 THEN

        #IO_com_hmi.IO_Type := 1;

    ELSE

        #IO_com_hmi.IO_Type := 0;

    END_IF;

    #IO_com_hmi.page_No := 1;

END_IF;


//in_out  mirror 

//copy input AND output

IF #IO_com_hmi.page_Btn[1] OR #IO_com_hmi.page_Btn[2] OR #IO_com_hmi.page_Btn[3] OR #IO_com_hmi.page_Btn[4] OR #IO_com_hmi.page_Btn[5]  THEN

    #IO_com_hmi.page_Btn[1] := false;

    #IO_com_hmi.page_Btn[2] := false;

    #IO_com_hmi.page_Btn[3] := false;

    #IO_com_hmi.page_Btn[4] := false;

    #IO_com_hmi.page_Btn[5] := false;

    

    //function  

    FOR #I := 1 TO #In_byte_No DO

        #IO_com_hmi.Input[#I] := PEEK(area := 16#81, dbNumber := 0, byteOffset := #I - 1);

    END_FOR;

    

    FOR #I := 1 TO #Out_byte_No DO

        #IO_com_hmi.Output[#I] := PEEK(area := 16#82, dbNumber := 0, byteOffset := #I - 1);

    END_FOR;

    

    //initial the page for i/o

    IF #IO_com_hmi.IO_Type = 0 THEN

(*_______________________input___________________*)

        IF #IO_com_hmi.page_No > #IO_com_hmi.Max_Page_In THEN

            #IO_com_hmi.page_No := 1;

        END_IF;

        IF #IO_com_hmi.page_No < 1 THEN

            #IO_com_hmi.page_No := #IO_com_hmi.Max_Page_In;

        END_IF;

        (*input status show in screen*)

        #IO_com_hmi.Cur_Status := #IO_com_hmi.Input[#IO_com_hmi.page_No];

        (*input text show in screen*)

        FOR #I := 0 TO 7 BY 1 DO

            #IO_com_hmi.Cur_Text[#I] := #I + 8 * (#IO_com_hmi.page_No - 1);  //renew io_list / io_no

        END_FOR;

    ELSE

    (*_______________________output___________________*)

        IF #IO_com_hmi.page_No > #IO_com_hmi.Max_Page_Out THEN

            #IO_com_hmi.page_No := 1;

        END_IF;

        IF #IO_com_hmi.page_No < 1 THEN

            #IO_com_hmi.page_No := #IO_com_hmi.Max_Page_Out;

        END_IF;

        //show Status

        #IO_com_hmi.Cur_Status := #IO_com_hmi.Output[#IO_com_hmi.page_No];

        //show text

        FOR #I := 0 TO 7 BY 1 DO

            #IO_com_hmi.Cur_Text[#I] := #I + 8 * (#IO_com_hmi.page_No - 1) + 500;//500 for demo output       

        END_FOR;

    END_IF;

END_IF;




热门招聘
相关主题

官方公众号

智造工程师