コード例 #1
0
ファイル: XinMingTianCtrl.cs プロジェクト: oliverhk/AutoScan
        private bool ReadCalib()
        {
            bool rect = false;

            try
            {
                string cmd    = "4052414158585858"; //@RAAXXXX
                string outStr = string.Empty;
                if (Write(cmd, ref outStr))
                {
                    //获取基础参数
                    basicPara = SplitPara(outStr);
                    //判断设备是否未上电,20181213,顾叶俊
                    if (basicPara.Load == 0 && basicPara.MaxShift == 0 &&
                        basicPara.MaxVoltage == 0 && basicPara.MinShift == 0 &&
                        basicPara.MinVoltage == 0 && basicPara.Power == 0)
                    {
                        rect = false;
                    }
                    else
                    {
                        rect = true;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
            return(rect);
        }
コード例 #2
0
ファイル: XinMingTianCtrl.cs プロジェクト: oliverhk/AutoScan
 public XinMingTianCtrl()
 {
     try
     {
         //open seril port
         ioSerialPort              = new SerialPort();
         ioSerialPort.PortName     = sysCfg.Pize_Serial_Port;
         ioSerialPort.BaudRate     = 9600;
         ioSerialPort.DataBits     = 8;
         ioSerialPort.Parity       = System.IO.Ports.Parity.None;
         ioSerialPort.StopBits     = System.IO.Ports.StopBits.One;
         ioSerialPort.ReadTimeout  = 1200;
         ioSerialPort.WriteTimeout = 1200;
         ioSerialPort.Open();
         basicPara = new PIZParaEntity();
     }
     catch (Exception ex)
     {
         LogHelper.AppLoger.Error(ex);
     }
 }
コード例 #3
0
ファイル: XinMingTianCtrl.cs プロジェクト: oliverhk/AutoScan
        private PIZParaEntity SplitPara(string strData)
        {
            PIZParaEntity rect = new PIZParaEntity();

            try
            {
                List <string> lstSplit = new List <string>();
                int           max      = strData.Length / 14;
                for (int i = 0; i < max; i++)
                {
                    lstSplit.Add(strData.Substring(14 * i, 14));
                }
                int HBit = 0;
                int LBit = 0;
                foreach (var v  in lstSplit)
                {
                    switch (v.Substring(0, 4))
                    {
                    case "4041":
                        //最小电压
                        HBit = Convert.ToInt16(v.Substring(4, 4), 16);
                        LBit = Convert.ToInt16(v.Substring(8, 4), 16);
                        if (HBit > 0 || LBit > 0)
                        {
                            rect.MinVoltage = float.Parse(string.Format("{0}.{1}", HBit, LBit));
                        }
                        break;

                    case "4042":
                        //最大电压
                        HBit = Convert.ToInt16(v.Substring(4, 4), 16);
                        LBit = Convert.ToInt16(v.Substring(8, 4), 16);
                        if (HBit > 0 || LBit > 0)
                        {
                            rect.MaxVoltage = float.Parse(string.Format("{0}.{1}", HBit, LBit));
                        }
                        break;

                    case "4043":
                        //最大位移
                        HBit = Convert.ToInt16(v.Substring(4, 4), 16);
                        LBit = Convert.ToInt16(v.Substring(8, 4), 16);
                        if (HBit > 0 || LBit > 0)
                        {
                            rect.MaxShift = float.Parse(string.Format("{0}.{1}", HBit, LBit));
                        }
                        break;

                    case "4044":
                        //负载
                        HBit = Convert.ToInt16(v.Substring(4, 4), 16);
                        LBit = Convert.ToInt16(v.Substring(8, 4), 16);
                        if (HBit > 0 || LBit > 0)
                        {
                            rect.Load = float.Parse(string.Format("{0}.{1}", HBit, LBit));
                        }
                        break;

                    case "4045":
                        //最小位移
                        HBit = Convert.ToInt16(v.Substring(4, 4), 16);
                        LBit = Convert.ToInt16(v.Substring(8, 4), 16);
                        if (HBit > 0 || LBit > 0)
                        {
                            rect.MinShift = float.Parse(string.Format("{0}.{1}", HBit, LBit));
                        }
                        break;

                    case "4046":
                        //功率
                        HBit = Convert.ToInt16(v.Substring(4, 4), 16);
                        LBit = Convert.ToInt16(v.Substring(8, 4), 16);
                        if (HBit > 0 || LBit > 0)
                        {
                            rect.Power = float.Parse(string.Format("{0}.{1}", HBit, LBit));
                        }
                        break;
                    }
                }
            }catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
            return(rect);
        }