鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 1328|鍥炲: 0

鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃

[澶嶅埗閾炬帴]
  • TA鐨勬瘡鏃ュ績鎯
    鎱垫噿
    2017-11-9 20:49
  • 绛惧埌澶╂暟: 2 澶

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2023-4-20 13:09:06 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃-1.png
    鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃-2.png





    鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃-3.png





    鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃-4.png




    涓銆佹杩

    鏈」鐩殑搴旂敤鍦烘櫙鏄疌NC鍔犲伐杞﹂棿銆
    1锛岄氳繃Codesys瀹氭椂涓诲姩杩炴帴骞朵笖浠ttp-post鐨勬柟寮忎笂浼犵姸鎬佷俊鎭埌web鏈嶅姟鍣(Node.js+Express)锛岃岀敤鎴烽氳繃PC銆佹墜鏈哄拰骞虫澘鐨勬祻瑙堝櫒璁块棶web鏈嶅姟鍣ㄨ幏鍙栬澶囩姸鎬佷俊鎭
    2锛孋odesys鍦ㄦ湁闇瑕佹椂鍊欎富鍔ㄨ繛鎺ュ苟涓斾互Tcp-Mysql鎶ユ枃鐨勬柟寮忔搷浣滄暟鎹簱(Mysql)锛岃幏鍙栫敓浜ч渶瑕佺殑璧勬枡(G鍔犲伐浠g爜)銆
    3锛岀敤鎴风粡杩嘝C銆佹墜鏈哄拰骞虫澘鐨勬祻瑙堝櫒璁块棶web鏈嶅姟鍣ㄦ潵鐏垫椿绠$悊淇濆瓨浜庢暟鎹簱鐨勭敓浜ц祫鏂欙紝瀹炵幇鐢熶骇璋冨害銆
    閫氳繃鏈」鐩睍绀 宸ヤ笟鐗╄仈缃戦」鐩殑璁惧涓婁簯鐨勫熀鏈鏋讹紝瀹炵幇 璁惧杩滅▼鏁板瓧鍖栫洃鎺с佺伒娲绘湁鏁堢殑鐢熶骇璋冨害杩欎袱涓伐涓氱墿鑱旂綉鐨勫叧閿兘鍔涖
    浜屻佷唬鐮佸睍绀

    2.1Codesys浠g爜

    2.1.1鏋舵瀯


    鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃-5.png





    鍒╃敤Codesys+Node.js+Mysql鏋勫缓CNC鏁板瓧杞﹂棿宸ヤ笟鐗╄仈缃-6.png




    2.1.2浠g爜

    鏈」鐩殑Codesys绋嬪簭娌跨敤浜嗘垜涔嬪墠鍗氭枃鐨勩WPF涓婁綅鏈+Codesys鐨凜NC鍦–odesys鍒╃敤Socket鎿嶄綔Mysql,鍥犳Servo銆丆NC鍜孧ysql鐨勪唬鐮侊紝灏变笉鍐嶅睍绀恒傛湰鏂囧彧灞曠ず鍏朵腑鐨 http-post閮ㄥ垎鍜孧ysql鐨勫簲鐢ㄩ儴鍒嗐
    2.1.2.1 WebUpInfo
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //浣滆咃細AlongWU
    TYPE WebUpInfo :
    STRUCT
        
    STR_EquipId              :STRING(30);              //璁惧ID
    R_V_X                    :REAL;                    //X浣嶇疆
    R_V_Y                    :REAL;                    //Y浣嶇疆
    R_V_Z                    :REAL;                    //Z浣嶇疆
    I_LineNo                 :DINT;                    //G浠g爜鐨勫綋鍓嶆墽琛岃鍙
    W_V_State                :WORD;                    //绋嬪簭鐘舵
     
    END_STRUCT
    END_TYPE

    2.1.2.2 Http_PostPacket_FB
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //浣滆咃細AlongWU
    FUNCTION_BLOCK Http_PostPacket_FB
    VAR CONSTANT
    abyEmpty               :ARRAY [0..999] OF BYTE;                //澶嶄綅鏁扮粍
    END_VAR
     
    VAR_INPUT
    STR_Url                :STRING(30);                            //post鎶ユ枃鐨剈rl瀛楁
    STR_Host               :STRING(30);                            //post鎶ユ枃鐨凥ost瀛楁
    Data                   :ARRAY[0..999]OF BYTE;                  //post鎶ユ枃 鏁版嵁瀛楄妭鏁扮粍
    DataLen                :INT;                                   //post鎶ユ枃 鏁版嵁瀛楄妭鏁扮粍鐨勫瓧鑺傛暟
     
    END_VAR
     
    VAR_OUTPUT
    Packet                  :ARRAY [0..999] OF BYTE;                //杈撳嚭post鎶ユ枃
    PacketSize              :UINT;                                  //post鎶ユ枃鐨勫瓧鑺傛暟
    END_VAR
     
    VAR
    HeaderLen                :INT;                                   //post鎶ユ枃header鐨勫瓧鑺傛暟
    STR_HttpHeader           :STRING(200);                           //post鎶ユ枃Header
    END_VAR
     
    //鏋勫缓鎶ユ枃header,  $0a 鏄崲琛岀 $0d 鏄洖杞︾
    STR_HttpHeader:=CONCAT('POST ',STR_Url); 
    STR_HttpHeader:=CONCAT(STR_HttpHeader,' HTTP/1.1$0d$0aAccept: */*$0d$0aAccept-Language: zh-CN$0d$0ahost:'); 
    STR_HttpHeader:=CONCAT(STR_HttpHeader,STR_Host);                     
    STR_HttpHeader:=CONCAT(STR_HttpHeader,'$0d$0aContent-TYPE: application/x-www-form-urlencoded$0d$0aConnection: close$0d$0aContent-Length: ');     
    STR_HttpHeader:=CONCAT(STR_HttpHeader,INT_TO_STRING(DataLen));
    STR_HttpHeader:=CONCAT(STR_HttpHeader,'$0d$0a$0d$0a');                            
     
    //Header鐨勫瓧鑺傛暟                                
    HeaderLen :=LEN(STR_HttpHeader);
     
    //澶嶄綅瀛楄妭鏁扮粍
    Packet :=abyEmpty;        
     
    //header澶嶅埗鍒 Packet
    MEM.MemMove(pSource:= ADR(STR_HttpHeader), pDestination:= ADR(Packet), uiNumberOfBytes:=INT_TO_UINT(HeaderLen));
     
    //data澶嶅埗鍒 Packet
    MEM.MemMove(pSource:= ADR(Data), pDestination:= ADR(Packet)+INT_TO_UINT(HeaderLen), uiNumberOfBytes:=INT_TO_UINT(DataLen));
     
    //packet鐨勬诲瓧鑺傛暟
    PacketSize :=INT_TO_UINT(HeaderLen + DataLen);

    2.1.2.3 TcpUpInfoClient
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //浣滆咃細AlongWU
    PROGRAM TcpUpInfoClient
     
    VAR CONSTANT
    abyEmpty                    :ARRAY [0..999] OF BYTE;                        //澶嶄綅鏁扮粍
    END_VAR
     
    VAR
    TCP_ClientFB                :NBS.TCP_Client;                                //TCP瀹㈡埛绔繛鎺ュ疄渚
    TCP_ReadFB                  :NBS.TCP_Read;                                  //TCP鎺ユ敹瀹炰緥
    TCP_WriteFB                 :NBS.TCP_Write;                                 //TCP鍙戦佸疄渚
    ServerIp                    :NBS.IP_ADDR:=(sAddr:='192.168.0.132');         //Tcp鏈嶅姟鍣ㄥ湴鍧
    ServerPort                  :UINT:=8100;                                    //Tcp鏈嶅姟鍣╬ort
    Enable_F_TRIG               :F_TRIG;                                        //閫氫俊浣胯兘涓嬮檷娌
    Enable_R_TRIG               :R_TRIG;                                        //閫氫俊浣胯兘涓婂崌娌
    Recei_R_TRIG                :R_TRIG;                                        //鎺ユ敹涓婂崌娌
    Close_R_TRIG                :R_TRIG;                                        //鍏抽棴杩炴帴涓婂崌娌
    Send_R_TRIG                 :R_TRIG;                                        //鍙戦佷笂鍗囨部
    WaitCount                   :UINT:=0;                                       //绌洪棽璁℃椂
    TryConnect                  :UINT;                                          //灏濊瘯杩炴帴娆℃暟
    STR_Url                     :STRING(30);                                  //post鎶ユ枃鐨剈rl瀛楁
    STR_Host                    :STRING(30);                                  //post鎶ユ枃鐨刪ost瀛楁
    ConnectActive_R_TRIG        :R_TRIG;                                        //TCP杩炴帴鎴愬姛涓婂崌娌
    W_state                     :WORD;                                          //绋嬪簭鐘舵佸
    UpInfo                      :WebUpInfo;                                    //web涓婁紶鏁版嵁鐨勭粨鏋勪綋
    Datalen                     :INT;                                         //post鎶ユ枃data鐨勫瓧鑺傛暟
    PostPacketFB                :Http_PostPacket_FB;                       //鏋勫缓post鎶ユ枃鍔熻兘鍧楃殑瀹炰緥
    UpInfoFB                    :WebUpInfoData_FB;                //鏋勫缓post鎶ユ枃鐨刣ata鐨勫姛鑳藉潡鐨勫疄渚
    UpInfoFB_Size               :INT;                             //鏋勫缓post鎶ユ枃鐨刣ata鐨勫姛鑳藉潡鐨勫瓧鑺傛暟
    UpInfoFB_Data               :ARRAY [0..999] OF BYTE;     //鏋勫缓post鎶ユ枃鐨刣ata鐨勫姛鑳藉潡鐨勮緭鍑哄瓧鑺傛暟缁
    END_VAR
     
     
     
    Enable_F_TRIG(CLK:=GVL.B_TcpUpInfo_Enable, Q=> );                                //浣胯兘涓嬮檷娌
    Enable_R_TRIG(CLK:=GVL.B_TcpUpInfo_Enable, Q=> );                                //浣胯兘涓婂崌娌
     
    Recei_R_TRIG(CLK:=TCP_ReadFB.xReady, Q=> );                                      //鎺ユ敹涓婂崌娌
     
    Send_R_TRIG(CLK:=(GVL.B_TcpUpInfo_Send), Q=> );                                  //鍙戦佷笂鍗囨部
    Close_R_TRIG(CLK:=GVL.B_TcpUpInfo_Close, Q=> );                                //鍏抽棴淇″彿涓婂崌娌
     
     
    IF Enable_F_TRIG.Q THEN
        //浣胯兘涓嬮檷娌匡紝澶嶄綅鐘舵
        GVL.B_TcpUpInfo_Send :=FALSE;
        GVL.TcpUpInfo_abyRx :=abyEmpty;
    END_IF
     
     
    IF Enable_R_TRIG.Q THEN
        //浣胯兘涓婂崌娌匡紝澶嶄綅鐘舵
        GVL.B_TcpUpInfo_OK :=FALSE;
        GVL.B_TcpUpInfo_FF :=FALSE;
        TryConnect:=0;
        WaitCount :=0;
        
    END_IF
     
    IF Send_R_TRIG.Q THEN
        //鍙戦佷笂鍗囨部锛屽浣嶇姸鎬
        GVL.B_TcpUpInfo_OK :=FALSE;
        GVL.B_TcpUpInfo_FF :=FALSE;
        WaitCount :=0;
        
            (*
     
    Http鎶ユ枃 渚嬪瓙
        
    POST /PlcUpInfo  HTTP/1.1
    Accept: */*
    Accept-Language: zh-CN
    host: localhost:8100
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 54
    Connection:close
     
    EquipId=E00001&V_X=10&V_Y=20&V_Z=30&LineNo=1&V_State=1
     
     
        *)
        
        //缁撴瀯浣撹祴鍊
        UpInfo.STR_EquipId := GVL.STR_EquipID;
        
        UpInfo.R_V_X :=LREAL_TO_REAL(GVL.X_Pos);
        UpInfo.R_V_Y :=LREAL_TO_REAL(GVL.Y_Pos);
        UpInfo.R_V_Z :=LREAL_TO_REAL(GVL.Z_Pos);
        UpInfo.I_LineNo :=DINT_TO_INT(GVL.D_LineNo);
        
        W_state.0 :=GVL.Interpolator.bBusy;
        W_state.1 :=GVL.Interpolator.bDone;
        UpInfo.W_V_State :=W_state;
        
        
        //鎵撳寘POST鎶ユ枃鐨 鏁版嵁鍖
        UpInfoFB(UpInfo:=UpInfo , Data=>UpInfoFB_Data , DataSize=>UpInfoFB_Size );
        
        STR_Url:='/PlcUpInfo';
        STR_Host:=CONCAT(ServerIp.sAddr,':'); 
        STR_Host:=CONCAT(STR_Host,UINT_TO_STRING(ServerPort)); 
        
        //鎵撳寘POST鎶ユ枃
        PostPacketFB(
        STR_Url:= STR_Url, 
        STR_Host:= STR_Host, 
        Data:= UpInfoFB_Data, 
        DataLen:= UpInfoFB_Size, 
        Packet=> GVL.TcpUpInfo_abyTx, 
        PacketSize=> GVL.TcpUpInfo_WriteSize);
        
    END_IF
     
     
     
     
    //TCP瀹㈡埛绔繛鎺ュ姛鑳藉潡
    TCP_ClientFB(
        xEnable:= GVL.B_TcpUpInfo_Enable, 
        xDone=> , 
        xBusy=> , 
        xError=> , 
        udiTimeOut:= 0, 
        ipAddr:= ServerIp, 
        uiPort:= ServerPort, 
        eError=> , 
        xActive=> , 
        hConnection=> );
     
        
    //TCP瀹㈡埛绔帴鏀跺姛鑳藉潡
    TCP_ReadFB(
        xEnable:= TCP_ClientFB.xActive, 
        xDone=> , 
        xBusy=> , 
        xError=> , 
        hConnection:= TCP_ClientFB.hConnection, 
        szSize:= 1000, 
        pData:= ADR(GVL.TcpUpInfo_abyRx), 
        eError=> , 
        xReady=> , 
        szCount=> );
        
    //TCP瀹㈡埛绔彂閫佸姛鑳藉潡
    TCP_WriteFB(
        xExecute:= GVL.B_TcpUpInfo_Send, 
        udiTimeOut:= 100, 
        xDone=> , 
        xBusy=> , 
        xError=> , 
        hConnection:= TCP_ClientFB.hConnection,  
        szSize:= GVL.TcpUpInfo_WriteSize, 
        pData:= ADR(GVL.TcpUpInfo_abyTx), 
        eError=> );
        
     
    //TCP杩炴帴鎴愬姛涓婂崌娌
    ConnectActive_R_TRIG(CLK:= TCP_ClientFB.xActive, Q=> );
     
        
    IF GVL.B_TcpUpInfo_Enable THEN
        IF ConnectActive_R_TRIG.Q THEN    
            //TCP涓婁紶鍔ㄤ綔浣胯兘鍚庯紝鎴愬姛寤虹珛杩炴帴鍚庯紝鍚姩鍙戦佸姩浣
            GVL.B_TcpUpInfo_Send := TRUE;            
        END_IF
    END_IF    
        
        
        
    //鍙戦佸畬鎴
    IF TCP_WriteFB.xDone THEN
        GVL.B_TcpUpInfo_Send :=FALSE;    
    END_IF
     
    //鍙戦佸悗锛寃eb鏈嶅姟杩斿洖缁撴灉锛屾柇寮杩炴帴
    IF GVL.B_TcpUpInfo_Enable THEN
        WaitCount := WaitCount +1;
        IF (WaitCount >5 AND GVL.B_TcpUpInfo_Close =FALSE) OR TCP_ReadFB.xReady THEN
            GVL.B_TcpUpInfo_Close := TRUE;
        END_IF
    END_IF
     
    IF Close_R_TRIG.Q THEN
        //鍏抽棴淇″彿涓婂崌娌匡紝澶嶄綅鐘舵
        GVL.B_TcpUpInfo_Close := FALSE;
        GVL.B_TcpUpInfo_Enable:=FALSE;
        GVL.B_TcpUpInfo_Send :=FALSE;    
    END_IF
     

    2.1.2.4 WebUpInfoData_FB
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //浣滆咃細AlongWU
    FUNCTION_BLOCK WebUpInfoData_FB
    VAR_INPUT
    UpInfo                      :WebUpInfo;                   //杈撳叆涓婁紶鏁版嵁缁撴瀯浣
    END_VAR
    VAR_OUTPUT
    Data                        :ARRAY[0..999]OF BYTE;       //杈撳嚭缁撴灉瀛楄妭鏁扮粍
    DataSize                    :INT;                        //杈撳嚭缁撴灉瀛楄妭鏁扮粍鐨勫瓧鑺傛暟
    END_VAR
    VAR
    STR_Data                    :STRING(255);
    END_VAR
     
     
    //鏋勫缓post鎶ユ枃鐨刣ata
     
    STR_Data:=CONCAT('EquipId=',UpInfo.STR_EquipId); 
    STR_Data:=CONCAT(STR_Data,'&V_X='); 
    STR_Data:=CONCAT(STR_Data,Real2Str(UpInfo.R_V_X,3)); 
    STR_Data:=CONCAT(STR_Data,'&V_Y='); 
    STR_Data:=CONCAT(STR_Data,Real2Str(UpInfo.R_V_Y,3)); 
    STR_Data:=CONCAT(STR_Data,'&V_Z='); 
    STR_Data:=CONCAT(STR_Data,Real2Str(UpInfo.R_V_Z,3)); 
    STR_Data:=CONCAT(STR_Data,'&LineNo='); 
    STR_Data:=CONCAT(STR_Data,DINT_TO_STRING(UpInfo.I_LineNo));     
    STR_Data:=CONCAT(STR_Data,'&V_State='); 
    STR_Data:=CONCAT(STR_Data,WORD_TO_STRING(UpInfo.W_V_State)); 
     
    //data鐨勫瓧鑺傛暟閲
    DataSize :=LEN(STR_Data);
     
    //瀛楃涓茶浆瀛楄妭鏁扮粍
    MEM.MemMove(pSource:= ADR(STR_Data), pDestination:= ADR(Data), uiNumberOfBytes:=INT_TO_UINT(DataSize));

    2.1.2.5 MysqlGetNewGcode
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //浣滆咃細AlongWU
    PROGRAM MysqlGetNewGcode
     
    VAR CONSTANT
    EmptyResult                  :ARRAY[0..5119] OF BYTE;            //澶嶄綅瀛楄妭鏁扮粍
    END_VAR
     
     
    VAR
    QueryStr                      :STRING(100);                        //鏌ヨ鍛戒护瀛楃涓
    QueryBytes                    :ARRAY[0..5119] OF BYTE;             //鏌ヨ鍛戒护buffer
    MysqlCmdPack                  :MysqlQueryCmdPack_FB;               //Mysql鎸囦护瀹炰緥
    MysqlFirstRowInfo             :MysqlRowInfo;                       //Mysql棣栬鏁版嵁缁撴瀯浣
    MysqlFirstRowDecode           :MysqlFirstRowData_FB;        //Mysql瑙f瀽鍥炲琛ㄦ牸淇℃伅骞舵彁鍙栭琛屾暟鎹
    GcodeBytes                    :ARRAY[0..5119] OF BYTE;             //鏌ヨ鍛戒护buffer
    tmpUint                       :UINT;
    tmpAddr                       :UINT;
    TxtWrite                      :TxtWrite_FB;                        //txt鍐欏叆鍔熻兘鍧楀疄渚
    TxtTruncate                   :TxtTruncate_FB;                     //txt娓呯┖鍔熻兘鍧楀疄渚
    GcodeSize                     :UINT;                               //NextGcode瀛楄妭鏁
    END_VAR
     
     
    CASE GVL.I_GetNextCodeStep OF 
            0:        
                QueryBytes := EmptyResult;                                   //鎸囦护buffer澶嶄綅
                
                IF GVL.B_Mysql_Inited THEN 
                    GVL.I_GetNextCodeStep := 10;                             //宸茶繛鎺ユ暟鎹簱
                ELSE
                    GVL.I_GetNextCodeStep := GVL.I_GetNextCodeStep +1;       //鏈繛鎺ユ暟鎹簱,涓嬩竴姝
                END_IF
            1:
                GVL.B_Mysql_Enable :=TRUE;
                GVL.I_GetNextCodeStep := GVL.I_GetNextCodeStep +1;           //涓嬩竴姝
            2:
                IF GVL.B_Mysql_Inited THEN         
                    GVL.I_GetNextCodeStep := 10;                              //宸茶繛鎺ユ暟鎹簱
                END_IF
                
                IF GVL.B_Mysql_AuthFalure THEN                                //杩炴帴澶辫触锛屾帹鍑虹櫥褰
                    GVL.I_GetNextCodeStep := 99;
                END_IF
            10:
                GVL.B_Mysql_Result :=FALSE;                                    //澶嶄綅鎺ユ敹瑙f瀽鏍囧織
                
                // '瑕佺敤$27鏉ヨ浆涔夛紝鐗规畩鐨勭鍙凤紝鐢$+16杩涘埗鐨刟csii鍊
                QueryStr :='SELECT `NextGcode` FROM `equiptable` WHERE `STATE`=1 AND `EquipId`=$27';
                QueryStr := CONCAT(QueryStr,GVL.STR_EquipID);
                QueryStr := CONCAT(QueryStr,'$27 LIMIT 1');
                MEM.MemMove(pSource:= ADR(QueryStr), pDestination:= ADR(QueryBytes), uiNumberOfBytes:=INT_TO_UINT(LEN(QueryStr)));
                //鏋勫缓cmd
                MysqlCmdPack(Cmd:=3 , InputBytes:= QueryBytes, Result=> GVL.Mysql_abyTx, ResultSize=>GVL.Mysql_WriteSize );        
                GVL.B_Mysql_Send :=TRUE;
                GVL.I_GetNextCodeStep := GVL.I_GetNextCodeStep +1;             //涓嬩竴姝
            11:
                IF GVL.B_Mysql_FF OR GVL.B_Mysql_FE THEN
                    GVL.I_GetNextCodeStep:=99;                                 //鏁版嵁搴撻敊璇紝閫鍑虹▼搴
                    RETURN;
                END_IF
            
                IF GVL.B_Mysql_Result THEN
                    MysqlFirstRowDecode(InputRxBytes:=GVL.Mysql_abyRx , FirstRowInfo=>MysqlFirstRowInfo );        //瑙f瀽row鏁版嵁
                    IF MysqlFirstRowInfo.IsNull THEN
                        //鍥炲涓虹┖锛屽嵆璇quipID娌℃湁鏁版嵁        
                        //NOTHING
                        GVL.I_GetNextCodeStep:=99;
                    ELSE
                        //鍥炲涓虹湡锛岃EquipID鏈塆浠g爜璧勬枡
                        TxtTruncate();                                                                            //閲嶇疆cnc鏂囦欢
                        GVL.I_GetNextCodeStep:=GVL.I_GetNextCodeStep +1;                        
                    END_IF                
                END_IF
            12:
                //璇诲彇mysql鍥炲鏁版嵁
                GcodeSize :=MysqlFirstRowInfo.RowData[0];
                MEM.MemMove(pSource:= ADR(MysqlFirstRowInfo.RowData)+1, pDestination:= ADR(GcodeBytes), uiNumberOfBytes:=GcodeSize);                
                //鍐欏叆骞舵洿鏂皌xt鏂囦欢
                TxtWrite(Buffer:=ADR(GcodeBytes), BufferLen:= GcodeSize);    
                GVL.I_GetNextCodeStep:=GVL.I_GetNextCodeStep +1;    
            13:
                // 鏇存柊ActiveGcode
                QueryStr :='UPDATE `equiptable` SET `ActiveGcode`=$27';
                tmpUint :=INT_TO_UINT(LEN(QueryStr));
                MEM.MemMove(pSource:= ADR(QueryStr), pDestination:= ADR(QueryBytes), uiNumberOfBytes:=tmpUint);
            
                tmpAddr := tmpUint;
                //Gcode澶嶅埗鍒板懡浠や腑
                MEM.MemMove(pSource:= ADR(GcodeBytes), pDestination:= ADR(QueryBytes)+tmpAddr, uiNumberOfBytes:=GcodeSize);
            
                tmpAddr := tmpAddr + GcodeSize;
                
                QueryStr :='$27 WHERE `EquipId`=$27';
                QueryStr := CONCAT(QueryStr,GVL.STR_EquipID);
                QueryStr := CONCAT(QueryStr,'$27');
                
                MEM.MemMove(pSource:= ADR(QueryStr), pDestination:= ADR(QueryBytes)+tmpAddr, uiNumberOfBytes:=INT_TO_UINT(LEN(QueryStr)));
                //鏋勫缓cmd
                MysqlCmdPack(Cmd:=3 , InputBytes:= QueryBytes, Result=> GVL.Mysql_abyTx, ResultSize=>GVL.Mysql_WriteSize );        
                GVL.B_Mysql_Send :=TRUE;
                GVL.I_GetNextCodeStep := GVL.I_GetNextCodeStep +1;                                                //涓嬩竴姝
            14:
                IF GVL.B_Mysql_FF OR GVL.B_Mysql_FE OR  GVL.B_Mysql_OK THEN
                    GVL.I_GetNextCodeStep:=99;                                            
                END_IF            
            99:            
                GVL.I_GetNextCodeStep:=100;
    ELSE        
        GVL.B_GetNextCode:=FALSE;
        GVL.B_GetNextCodeTask:=FALSE;
    END_CASE
     
     
    //mysql閿欒澶勭悊
    IF GVL.B_Mysql_AuthFalure THEN
        GVL.B_GetNextCode := FALSE;
        GVL.B_GetNextCodeTask:=FALSE;
    END_IF

    2.1.2.6 PLC_PRG
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //浣滆:AlongWu
    PROGRAM PLC_PRG
    VAR
        
    ReadFileTask_F_TRIG             :F_TRIG;                //璇诲彇cnc鏂囦欢鏍囧織涓嬮檷娌
    Cnc_Start_R_TRIG                :R_TRIG;                //cnc鎵ц鏍囧織涓婂崌娌
    B_MysqlGetGCode_R_TRIG          :R_TRIG;                //Mysql鏇存柊G浠g爜涓婂崌娌
    UpBlink                         :INT:=0;                //http post鐨勫欢鏃惰鏁
     
    END_VAR
     
    //cnc鎵ц鏍囧織涓婂崌娌
    Cnc_Start_R_TRIG(CLK:= GVL.B_Cnc_Start, Q=> );
     
    IF Cnc_Start_R_TRIG.Q THEN
        //璇诲彇cnc鏂囦欢鏍囧織鍜岃鍙栨枃浠禩ask鐨勮Е鍙戞爣蹇楋紝缃甌RUE銆
        GVL.B_ReadFile:=TRUE;
        GVL.B_ReadFileTask:=TRUE;
    END_IF
     
    //璇诲彇txt鏂囦欢鏍囧織涓嬮檷娌
    ReadFileTask_F_TRIG(CLK:= GVL.B_ReadFileTask, Q=> );
     
    IF ReadFileTask_F_TRIG.Q THEN
        //璇诲彇cnc骞惰В鏋愬悗锛屽惎鍔ㄦ彃琛ュ櫒
        GVL.B_Cnc_Ipo:= TRUE;
        GVL.B_Cnc_Start :=FALSE;
    END_IF
     
     
    //閫氳繃Mysql鑾峰彇 NextGCode
    B_MysqlGetGCode_R_TRIG(CLK:=GVL.B_GetNextCode , Q=> );                                                
     
    IF B_MysqlGetGCode_R_TRIG.Q THEN
        //鍚姩Mysql鑾峰彇NextGCode
        GVL.I_GetNextCodeStep := 0;    
        GVL.B_GetNextCodeTask :=TRUE;
        GVL.B_Mysql_AuthFalure :=FALSE;
    END_IF
     
    (*http post 涓婁紶鏁版嵁*)
    IF UpBlink < 2 THEN
        UpBlink :=UpBlink+1;
    ELSE
        //姣2涓懆鏈熶笂浼犱竴娆
        GVL.B_TcpUpInfo_Enable:= TRUE;
        UpBlink:=0;
    END_IF

    2.2鏈嶅姟鍣ㄧNode.js浠g爜
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //------------const end------------
     
    const express = require('express');
    const mysql = require('mysql');
    const bodyParser = require('body-parser');
     
    // 鍒涘缓web鏈嶅姟鍣
    const app = express();
     
    //mysql connection
    const connection = mysql.createConnection({
        host     : 'localhost',
        user     : 'testNode',
        password : 'testNode',
        database : 'testcnc'
      });
     
    //------------const end--------------
     
    //------------class start------------
     
    class PLC {
        constructor(EquipId, Name,TouchCount,V_X,V_Y,V_Z,V_LineNo,V_State,ActGcode,NextGcode,sqlState) {
          this.EquipId = EquipId
          this.Name = Name
          this.V_X = V_X
          this.V_Y = V_Y
          this.V_Z = V_Z
          this.V_LineNo = V_LineNo
          this.V_State = V_State
          this.TouchCount = TouchCount
          this.ActGcode = ActGcode
          this.NextGcode = NextGcode
          this.sqlState = sqlState
        }
      
      }
     
     //------------class end--------------
     
    //------------object start------------
     
    //plc鍙橀噺鍊 Json瀵硅薄
    var tmpPlcVars =
    {
        EquipId:'',
        Name:'',
        X:0,
        Y:0,
        Z:0,
        LineNo:0,
        TouchCount:0,
        State:0
    };
     
    var tmpGcodeVars =
    {
        EquipId:'',
        ActGcode:'',
        NextGcode:'',
        res:0
    };
     
    //------------object end------------
     
    //------------var start-------------
       
      //PLC鐨刢lass鏁扮粍
      var PLC_ArrList = new Array();
     // 鍒涘缓 application/x-www-form-urlencoded 缂栫爜瑙f瀽
      var urlencodedParser = bodyParser.urlencoded({ extended: false })
     
    //------------var end---------------
      
    //------------ function start-------
     
    //鏌ヨmysql璁惧淇℃伅琛
     function  QueryEquipList()
    {
       connection.query('SELECT * FROM equiptable WHERE STATE=1', function (error, results) {
           if(error){       
               console.log('[SELECT ERROR] - ',error.message);
               return;
             }
            let rowResult;
            let tmpPlc;
            let n,h,i,j;
            let TmpPlcList;
            h = results.length;
            n = PLC_ArrList.length;
           
           /*
             1锛屾煡璇ysql鏁版嵁搴擄紝鑾峰彇褰撳墠鑳界敤鐨別quiplist銆
             2锛屾煡璇㈢粨鏋滆窡褰撳墠鐨凱LC_ArrList杩涜锛屾暟鎹洿鏂板苟涓 mysql鏁版嵁搴撴爣娉ㄤ负鍙敤鐨勶紝鏇存柊PLC_ArrList椤圭殑sqlState锛涘鏋滄湁鏂板锛宲ush娣诲姞銆
             3锛屽皢PLC_ArrList椤圭殑sqlState涓0 鐨勫墧闄わ紝骞堕噸鏂板缓绔婸LC_ArrList銆
           */
     
     
            if(h > 0)
            {        
               //鍏ㄩ儴plc鐨剆qlstate缃0   
               for(i=0;i < n;i++ )
              {
                PLC_ArrList[i].sqlState = 0;
              }
             
               //濡傛灉PLC_ArrList鐨勯」鍦╩ysql浠嶇劧鏈夎褰曪紝鍒檚qlstate缃1
               for ( i=0; i<h; i++) 
               {                  
                   rowResult = results[i];             
                   for( j=0;j < n;j++ )
                   {
                       if(rowResult['EquipId'] == PLC_ArrList[j].EquipId)
                       {
                        //鎵惧埌PLC_ArrList鐨勪綅缃紝鏇存柊ActiveGcode鍜孨extGcode銆
                           PLC_ArrList[j].ActiveGcode = rowResult['ActiveGcode'];
                           PLC_ArrList[j].NextGcode = rowResult['NextGcode'];
                           PLC_ArrList[j].sqlState = 1;
                           break;
                       }
     
                   }
     
                   //PLC_ArrList娌℃湁璁板綍锛宲ush鏂板
                   if(j == n)
                   {
                       tmpPlc = new PLC(rowResult['EquipId'],rowResult['Name'],0,0,0,0,0,0,rowResult['ActiveGcode'],rowResult['NextGcode'],1);                      
                       PLC_ArrList.push(tmpPlc);        
                          
                   }
               }
     
               //鏇存柊 PLC_ArrList鐨勬暟閲
               n = PLC_ArrList.length;
     
               TmpPlcList = new Array();
     
               //鎶 PLC_ArrList鏁扮粍 澶嶅埗鍒 TmpPlcList
               for (i=0; i<n; i++) 
               {
                   TmpPlcList.push(PLC_ArrList.pop());
               }
     
               //PLC_ArrList澶嶄綅
               PLC_ArrList = new Array();
     
               for (i=0; i<n; i++) 
               {
                   tmpPlc = TmpPlcList.pop();
     
                   if(tmpPlc.sqlState == 1)
                   {
                       //濡傛灉 sqlState=1锛岄噸鏂板帇鍥 PLC_ArrList
                       PLC_ArrList.push(tmpPlc);
                   }
               }
           }        
       });
       
    }
     
    //鏇存柊mysql璁惧鐨凣浠g爜鏁版嵁椤
    function MysqlUpdateGCode(equipid,newcode)
    {
        connection.query("UPDATE equiptable SET NextGcode='"+newcode+"' WHERE EquipId='"+equipid+"'", function (error, results) {
            if(error){       
                console.log('[SELECT ERROR] - ',error.message);
                return;
              }    
           });
    }
     
    //鏋勫缓express(web鏈嶅姟鍣)
    function InitExpress()
    {
     
    // 鍚姩鏈嶅姟鍣
    app.listen(8100, () => {
       console.log('express server running at http://127.0.0.1')
    });
     
    //use鏂规硶锛岄潤鎬佽矾鐢
    app.use( express.static('page'));
     
    //State鎸囦护鐨勫鐞
    app.get('/State', (req, res) => {  
       let id = req.query.EquipId;
       n = PLC_ArrList.length;
       if( n >0)
       {
           for(i=0;i<n;i++)
           {
               if(PLC_ArrList[i].EquipId == id)
               {             
                   break;
               }
           }
     
           if(n == i)
           {          
               //璁惧鏈櫥璁
               tmpPlcVars.EquipId ='';
               tmpPlcVars.Name ='';
               tmpPlcVars.X = 0;
               tmpPlcVars.Y = 0;
               tmpPlcVars.Z = 0;
               tmpPlcVars.LineNo = 0;
               tmpPlcVars.State = 0;
               tmpPlcVars.TouchCount = 0;   
           }
           else
           {
               //璁惧宸茬櫥璁
               //鏇存柊Plc鏁扮粍鐨勪俊鎭
               tmpPlcVars.EquipId  = PLC_ArrList[i].EquipId;
               tmpPlcVars.Name  = PLC_ArrList[i].Name;    
               tmpPlcVars.X =  PLC_ArrList[i].V_X;
               tmpPlcVars.Y =  PLC_ArrList[i].V_Y;
               tmpPlcVars.Z =  PLC_ArrList[i].V_Z;
               tmpPlcVars.LineNo = PLC_ArrList[i].LineNo;
               tmpPlcVars.State = PLC_ArrList[i].V_State;
               tmpPlcVars.TouchCount = PLC_ArrList[i].TouchCount;          
           }
       }
     //鍥炲鐢ㄦ埛娴忚鍣
       res.send(JSON.stringify(tmpPlcVars));
    });
     
    //Fresh G Code鎸囦护鐨勫鐞
    app.get('/FreshGode', urlencodedParser, function (req, res) {
       
       let id = req.query.EquipId;
     
       let i,n;
     
       n = PLC_ArrList.length;
     
       for(i=0;i<n;i++)
        {
           if(PLC_ArrList[i].EquipId == id)
           {
               break;
           }
        }
        if(i<n)
        {
            //濡傛灉鎵鏌ユ壘鐨凟quipId鍦≒LC_ArrList鏁扮粍鍐咃紝鍒欒祴鍊紅mpGcodeVars銆
           tmpGcodeVars.EquipId = id;
           tmpGcodeVars.ActGcode = PLC_ArrList[i].ActGcode;
           tmpGcodeVars.NextGcode = PLC_ArrList[i].NextGcode;
           tmpGcodeVars.res = 1;
        }
        else
        {
           //濡傛灉鎵鏌ユ壘鐨凟quipId涓嶅湪PLC_ArrList鏁扮粍鍐咃紝鍒欏洖澶嶆煡璇㈠け璐ャ
           tmpGcodeVars.EquipId = "";
           tmpGcodeVars.ActGcode = "";
           tmpGcodeVars.NextGcode ="";
           tmpGcodeVars.res = 0;
        }
       
        //鍥炲鐢ㄦ埛娴忚鍣
       res.send(JSON.stringify(tmpGcodeVars));
       
    })
     
    //Plc涓婁紶鏁版嵁 PlcUpInfo鎸囦护鐨勫鐞
    app.post('/PlcUpInfo', urlencodedParser, function (req, res) {
       let id = req.body.EquipId;
       let i,n;
       n = PLC_ArrList.length;
     
       if( n >0)
       {
           for(i=0;i<n;i++)
           {
               if(PLC_ArrList[i].EquipId == id)
               {
                   break;
               }
           }
     
           if(n == i)
           {
               //璁惧鏈櫥璁
               //nothing
               console.log('no equip');
           }
           else
           {
            
               //璁惧宸茬櫥璁
               //鏇存柊Plc鏁扮粍鐨勪俊鎭
               PLC_ArrList[i].V_X = req.body.V_X;
               PLC_ArrList[i].V_Y = req.body.V_Y;
               PLC_ArrList[i].V_Z = req.body.V_Z;
               PLC_ArrList[i].LineNo = req.body.LineNo;
               PLC_ArrList[i].V_State = req.body.V_State;
               PLC_ArrList[i].TouchCount = PLC_ArrList[i].TouchCount + 1;          
     
                if(PLC_ArrList[i].TouchCount > 10000)
                {
                  PLC_ArrList[i].TouchCount =0;
                }
     
           }
       }
       res.end();//缁撴潫杩涚▼
      
    })
     
    //web瀵煎叆鏂癎code
    app.post('/Newgcode', urlencodedParser, function (req, res) {
        let id = req.body.EquipId;
        let i,n;
        n = PLC_ArrList.length;
        if( n >0)
        {
            for(i=0;i<n;i++)
            {
                if(PLC_ArrList[i].EquipId == id)
                {
                    break;
                }
            }
     
            if(n == i)
            {
                //璁惧鏈櫥璁           
                res.send('EquipId:'+id+" 涓嶅彲鐢ㄣ");
            }
            else
            {
                //璁惧宸茬櫥璁
                MysqlUpdateGCode(id,req.body.gc);
                res.send('鏂癎浠g爜宸叉洿鏂'); 
            }
        }
     
     })
    }
     
    //瀹氭椂寰幆浠诲姟鍑芥暟
    function CircleTask1()
    {
        QueryEquipList();   //鏌ヨmysql锛岃幏鍙栨渶鏂癳quiplist
    }
     
    //------------ function end----------
     
    //------------Main function start----
     
    function MainFunction (){
     
        InitExpress();                      //寤虹珛Web鏈嶅姟鍣 express
        console.log('宸插缓绔婨xpress');
        銆銆    
        //寤虹珛mysql闀胯繛鎺
        connection.connect(function(err,data){
            if(err)
            {銆
                throw err銆銆         
                return;                      //mysql涓嶅彲鐢紝閫鍑虹▼搴
            }else
            {
                //杩炴帴鎴愬姛銆銆          
                console.log('宸茶繛鎺ysql');   
            }});
                                            
        QueryEquipList();                   //绗竴娆℃煡璇ysql锛岃幏鍙栨渶鏂癳quiplist
     
        setInterval(CircleTask1,2000);      //鍚姩瀹氭椂浠诲姟1锛屽懆鏈2s
        console.log('宸插惎鍔ㄥ畾鏃跺惊鐜换鍔');
         
    };
     
    MainFunction();                         //鍚姩MainFunction
     
    //------------Main function end----
     

    2.3瀹㈡埛绔疕tml+鍘熺敓js
    [HTML] 绾枃鏈煡鐪 澶嶅埗浠g爜
    <html>
    <head>
    <style type="text/css">
    .mbutton {
        height: 45px;
        width: 100px;
    }
     
    .mtable{
      border:1px;
      border-style: solid;
      width: 850px;
      height: 350px;
      border-collapse: collapse;
    }
     
    .mtextarea{
      width: 250px;
      height: 400px;
      overflow-y: auto;
    }
     
    .codeSp
    {
      background-color: lightgray;
    }
     
    .mtr{
      height: 50px;
    }
    </style>
     
     
     
    <script type="text/javascript">
     
    //------------var start------------
     
    var GcodeTxt ;
    var TmpActGcode='';
    var T_CircleQuery,T_ReplyCheck;
    var LostConnect =0;
    var EquipId = 'E00001';
    var TouchCount = 0,LastTouchCount = 0;
    var SendLock=0;
    var PlcOnline=0;
    var codeArr;
     
    //delay鍑芥暟
    const delay = ms => new Promise((resolve, reject) => setTimeout(resolve, ms))
     
     
    //------------var end------------
     
     
    //涓诲嚱鏁
    function MainFuncion()
    {
      console.log("鍚姩寰幆鏌ヨ");
      var t=0;
     
      //鏋勫缓瀹氭椂寰幆浠诲姟
      var CircleAsyncTask = async() =>{ 
        while(LostConnect == 0)
        {
          
          if(t<10)
          {
            //姣0.2s鏌ヨ涓娆$姸鎬
            QueryFunc();
            t++;
          }
          else
          {
            //姣2s鏌ヨ涓娆浠g爜
            GetGodeFunc();
            t=0;
     
            if(LastTouchCount != TouchCount)
            {
              document.getElementById("onLine").textContent ='鍦ㄧ嚎涓';
              PlcOnline=1;
            }
            else
            {
              document.getElementById("onLine").textContent ='鏈繛鎺';
              PlcOnline=0;
            }
     
            //鏇存柊TouchCount
            LastTouchCount = TouchCount;
     
          }
          //寮傛寰幆
          await delay(200)
        }
      console.log("缁撴潫寰幆鏌ヨ");
      };
     
      //鍚姩瀹氭椂寰幆浠诲姟
      CircleAsyncTask();  
     
    }
     
    //G浠g爜涓婁紶鍑芥暟
    function TxtUpload(input) {  
                //鏀寔chrome IE10  
                if (window.FileReader) {                 
                    var reader = new FileReader();  
                    var file = input.files[0];  
                    //鏋勫缓reader
                    reader.onload = function() {  
                        GcodeTxt = this.result;  
                        //鎶奣xt鏂囦欢鐨凣浠g爜鍙戦佸埌鏈嶅姟鍣
                        SendGodeFunc();
                    }  
                    reader.readAsText(file);  
                }   
              
            }  
     
    //鍙戦丟浠g爜鑷虫湇鍔″櫒鐨勫嚱鏁
    function SendGodeFunc()
    {
      let xmlhttp;
      let postCode;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            //澶嶄綅Ajax鍝嶅簲璁℃椂
          clearTimeout(T_ReplyCheck);
          SendLock=0;
        }
      }
     
     
    xmlhttp.open("post","/Newgcode",true);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");   
    postCode ="EquipId="+EquipId+"&gc="+GcodeTxt;
     
    while(SendLock==1)
    {
      //wait
    }
    xmlhttp.send(postCode);
    SendLock=1;
    //鍚姩Ajax鍝嶅簲璁℃椂
    T_ReplyCheck =setTimeout("AjaxRelyFalure()", 100);  
     
    }
     
    //鏌ヨ褰撳墠璁惧鐘舵佺殑鍑芥暟
    function QueryFunc()
    {
    let xmlhttp;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
          //澶嶄綅Ajax鍝嶅簲璁℃椂
          clearTimeout(T_ReplyCheck);
          SendLock =0;
          let PlcObj = JSON.parse(xmlhttp.responseText);
     
          document.getElementById("Plc_X").textContent = PlcObj.X;
          document.getElementById("Plc_Y").textContent = PlcObj.Y;
          document.getElementById("Plc_Z").textContent = PlcObj.Z;
          
          if(parseInt(PlcObj.State) == 0)
          {
            document.getElementById("Plc_State").textContent = "寰呮満";
         
          }
          else
          {
            document.getElementById("Plc_State").textContent = "鍔犲伐涓";
          }
     
          TouchCount = parseInt(PlcObj.TouchCount);
     
          let lineNo = parseInt(PlcObj.LineNo);
          
          if(lineNo ==-1 || PlcOnline == 0)
          {
            document.getElementById("ActGcode").innerHTML =TmpActGcode;
          }
          else
          {
              
              let n = codeArr.length;
              let i;
              let code='';
              if(n>0)
              {
                for(i=0;i<n;i++)
                {
                    if(i == lineNo)
                    {
                      code = code + "<span class='codeSp'>"+codeArr[i]+'</span><br>';
                    }
                    else
                    {
                      code = code + codeArr[i]+'<br>';
                    }
                }
                document.getElementById("ActGcode").innerHTML =code;
                
              }
     
          }
     
     
        }
      }
    xmlhttp.open("get","/State?EquipId="+EquipId,true);
    xmlhttp.setRequestHeader("Content-Type", "text/html");   
     
    while(SendLock==1)
    {
      //wait
    }
     
    xmlhttp.send();
    SendLock = 1;
    //鍚姩Ajax鍝嶅簲璁℃椂
    T_ReplyCheck =setTimeout("AjaxRelyFalure()", 100);  
    }
     
    //鏌ヨ褰撳墠璁惧G浠g爜鐨勫嚱鏁
    function GetGodeFunc()
    {
      let xmlhttp;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            //澶嶄綅Ajax鍝嶅簲璁℃椂
          clearTimeout(T_ReplyCheck);
          SendLock = 0;
          let GcodeObj = JSON.parse(xmlhttp.responseText);
         
          if(GcodeObj.res == 1)
          {
            codeArr = (GcodeObj.ActGcode).split('\r\n');       
            TmpActGcode = (GcodeObj.ActGcode).replace(/\r\n/g,'<br>');        
            document.getElementById("NextGcode").innerHTML = (GcodeObj.NextGcode).replace(/\r\n/g,'<br>');     
          }
          else
          {
            document.getElementById("ActGcode").innerHTML ='';
            document.getElementById("NextGcode").innerHTML= '';
          }
        }
      }
    xmlhttp.open("get","/FreshGode?EquipId="+EquipId,true);
    xmlhttp.setRequestHeader("Content-Type", "text/html");   
     
    while(SendLock==1)
    {
      //wait
    }
    xmlhttp.send();
    SendLock = 1;
    //鍚姩Ajax鍝嶅簲璁℃椂
    T_ReplyCheck =setTimeout("AjaxRelyFalure()", 100);  
     
    }
     
    //ajax鎺ユ敹瓒呮椂鎶ヨ鍑芥暟
    function AjaxRelyFalure()
    {
      SendLock=0;
      LostConnect = 1 ;
      alert("鏈嶅姟鍣ㄨ繛鎺ュけ璐ワ紝璇峰埛鏂伴〉闈");
    }
     
     
    //椤甸潰鍔犺浇瀹屾垚鍚庯紝鍚姩涓诲嚱鏁
    window.onload = function(){
                //椤甸潰鍔犺浇鍗虫墽琛屽嚱鏁
                MainFuncion();
            }
     
     
    </script>
    </head>
    <body>
     
    <h2>NodeJs+Codesys</h2>
    <table class="mtable" cellspacing="0">
    <tr>
      <td width="250">
        <table cellspacing="0">
          <tr>
            <td><h3>璁惧鎵цG浠g爜</h3></td>
          </tr>
          <tr>
            <td><div id="ActGcode" class="mtextarea"></div></td>
          </tr>
          
        </table>
      </td>
      <td width="250">
        <table cellspacing="0">
          <tr>
            <td><h3>璁惧涓嬩竴涓狦浠g爜</h3></td>
          </tr>
          <tr>
            <td><div id="NextGcode" class="mtextarea"></div></td>
          </tr>
          
        </table>
      </td>
      <td width="350">
        <table>
          <tr class="mtr">
            <td width="90px">
              <h3>X</h3>
            </td>
            <td>
              <h2 id="Plc_X"></h2>
            </td>
          </tr>
          <tr class="mtr">
            <td >
              <h3>Y</h3>
            </td>
            <td>
              <h2 id="Plc_Y"></h2>
            </td>
          </tr>
          <tr class="mtr">
            <td >
              <h3>Z</h3>
            </td>
            <td>
              <h2 id="Plc_Z"></h2>
            </td>
          </tr>
          <tr class="mtr">
            <td >
              璁惧鐘舵
            </td>
            <td>
              <span id="Plc_State"></span>
            </td>
          </tr>
          <tr class="mtr">
            <td >
              鍦ㄧ嚎鐘舵
            </td>
            <td>
              <span id="onLine"></span>
            </td>
          </tr>
     
          <tr class="mtr">
            <td valign="middle">
              瀵煎叆
            </td>
            <td >
              <input type="file" />
            </td>
          </tr>
        </table>
      </td>
    </tr>
    </table>
     
    </body>
    </html>

    涓夈佹荤粨

    鏈」鐩氳繃CNC鐨凣浠g爜鐨勮仈缃戞暟鎹簱璋冪敤鍜岀鐞嗭紝灞曠ず浜咰odesys+Node.js+Mysql鐨勫伐涓氱墿鑱旂綉搴旂敤鐨勫熀鏈瀯鏋跺拰瀹炵幇銆傞」鐩疄鐜扮殑鍔熻兘铏界劧姣旇緝绠鍗曪紝浣嗗熀鏈綋鐜颁簡宸ヤ笟鐗╄仈缃戠殑鐗规у拰搴旂敤銆
    Codesys閫氳繃http鎶ユ枃涓巜eb绯荤粺浜や簰锛屾剰鍛崇潃web鏈嶅姟鍣ㄨ蒋浠朵笉闄愪簬Node.js+express锛岃繕鍙互PHP+apache 銆 Asp.net+iis 绛夌瓑鍏ㄩ儴web鏈嶅姟鍣ㄧ郴缁熴傚墠绔笉闄愪簬鍘熺敓js锛岃繕鍙互Vue銆丷eact绛夌瓑鐨勫叏閮⊿PA鐨勬鏋躲
    Codesys閫氳繃Tcp鎶ユ枃涓庢暟鎹簱绯荤粺浜や簰锛屾剰鍛崇潃鏁版嵁搴撲笉闄愪簬Mysql锛岃繕鍙互鍦╟odesys寮鍙戠浉搴旀暟鎹簱鐨勬搷浣滃瓙绋嬪簭鏉ヤ娇鐢∣racle銆丼QLServer绛夌瓑銆
    鍩轰簬Codesys鐨剆ocket鑳藉姏锛屽彲浠ュ崄鍒嗙伒娲诲拰渚挎嵎鍦板鎺ユ湇鍔″櫒杞欢(Web, ERP,MES绛夌瓑)锛屽疄鐜拌澶囩殑鑱旂綉锛岃繘鑰屽疄鐜拌澶囨暟瀛楀寲绠$悊鍜屼娇鐢ㄣ
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

    鎮ㄩ渶瑕佺櫥褰曞悗鎵嶅彲浠ュ洖甯 鐧诲綍 | 绔嬪嵆娉ㄥ唽 鏂版氮寰崥鐧婚檰

    鏈増绉垎瑙勫垯

    椤堕儴qrcode搴曢儴
    鍏虫敞閰峰痉缃戣闃呭彿锛岃幏鍙栨洿澶氳祫璁紒

    QQ|灏忛粦灞|鎵嬫満鐗|Archiver|閰峰痉璁哄潧 ( 鑻廔CP澶16065247鍙-1 )|缃戠珯鍦板浘

    GMT+8, 2024-11-27 12:25 , Processed in 0.156245 second(s), 60 queries .

    閰峰痉缃

    © 2001-2013 Hicodesys. 鎶鏈敮鎸 by 閰峰痉缃

    蹇熷洖澶 杩斿洖椤堕儴 杩斿洖鍒楄〃