コード例 #1
0
        public static bool ReadRecordSingle(int master, int dct, out int record)
        {
            bool result = false;

            record = -1;
            try
            {
                string send = PLC_Tcp_CP.Get16String(master, 2) + Order_Record_Read_Master + PLC_Tcp_CP.Get16String(dct, 2);
                string response;
                int    err; string errStr;
                int    num = 0;
                do
                {
                    num++;
                    bool b = SendPLC_DPJ_485(send, new StackTrace().GetFrame(0).GetMethod().ToString(), out response, out err, out errStr);
                    if (b)
                    {
                        result = false;
                        record = PLC_Tcp_CP.Get16Int(response.Substring(10, 2));
                        break;
                    }
                    else if (err != 3)
                    {
                        result = false;
                        //csLog.WriteLog(errStr);
                        break;
                    }
                } while (err == 3 && num < 3);
            }
            catch (Exception ex)
            {
                csLog.WriteLog(ex.Message);
            }
            return(result);
        }
コード例 #2
0
        const int BaffleManualMoveStatus_Down = 6;//D-1
        public static bool Baffle_Lift_IsMinDown()
        {
            bool   result = false;
            string send   = RegDR + PLC_Tcp_CP.GetAdrD_1000(BaffleManualMoveStatus_Down) + "0001";
            string response;

            if (SendPLC(send, "出药挡板状态", out response))
            {
                int i = response.IndexOf(":");
                if (i >= 0)
                {
                    if (PLC_Tcp_CP.Get16Int(response.Substring(i + 7, 4)) == 1)
                    {
                        result = true;
                    }
                }
            }
            if (!result)
            {
                send = RegDR + PLC_Tcp_CP.GetAdrD_1000(BaffleAutoMoveStatus_Down) + "0001";
                if (SendPLC(send, "出药挡板状态", out response))
                {
                    int i = response.IndexOf(":");
                    if (i >= 0)
                    {
                        if (PLC_Tcp_CP.Get16Int(response.Substring(i + 7, 4)) == 2)
                        {
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        //计算FCS码
        static string GetFCS(String value)
        {
            int f = 0;
            int j = value.Length;

            for (int i = 0; i < j; i += 2)
            {
                int x = PLC_Tcp_CP.Get16Int(value.Substring(i, 2));
                //每次进行异或运算
                f = f ^ x;
            }
            //转换为16进制
            return(f.ToString("X"));
        }
コード例 #4
0
        const int BafflePulse_Lift = 1336;//D-2
        //读取脉冲
        public static int ReadBafflePulse_Lift()
        {
            int    result = 0;
            string send   = RegDR + PLC_Tcp_CP.GetAdrD_1000(BafflePulse_Lift) + "0002";
            string response;

            if (SendPLC(send, "挡板脉冲", out response))
            {
                int i = response.IndexOf(":");
                if (i >= 0)
                {
                    string s = response.Substring(i + 7, 8);
                    result = PLC_Tcp_CP.Get16Int(s.Substring(4, 4) + s.Substring(0, 4));
                }
            }
            return(result);
        }
コード例 #5
0
        const int BaffleOrigin_State = 2;//D-1
        //挡板原点复位是否完成
        public static bool BaffleOriginResetIsOK()
        {
            bool   result = false;
            string send   = RegDR + PLC_Tcp_CP.GetAdrD_1000(BaffleOrigin_State) + "0001";
            string response;

            if (SendPLC(send, "挡板原点复位完成状态", out response))
            {
                int i = response.IndexOf(":");
                if (i >= 0)
                {
                    if (PLC_Tcp_CP.Get16Int(response.Substring(i + 7, 4)) == 1)
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
コード例 #6
0
        const int BaffleAutoMoveStatus_Up = 9;//D-1
        public static bool BaffleAutoMoveIsOK_Up()
        {
            bool   result = false;
            string send   = RegDR + PLC_Tcp_CP.GetAdrD_1000(BaffleAutoMoveStatus_Up) + "0001";
            string response;

            if (SendPLC(send, "挡板自动运行状态", out response))
            {
                int i = response.IndexOf(":");
                if (i >= 0)
                {
                    if (PLC_Tcp_CP.Get16Int(response.Substring(i + 7, 4)) == 1)
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }