Beispiel #1
0
        /// <summary>
        /// 启动所有需要的设备通讯线程
        /// </summary>
        public void StartUse()
        {
            try
            {
                int i = 0;//打开20次,有时仪表一次会打不开
                if (UseMeter)
                {
                    i = 0;
                    m_CoolSerialForMeter            = new CoolSerial(METERPARA);
                    m_CoolSerialForMeter.DeviceType = METERTYPE;//仪表类型,决定如何处理事务
                    m_CoolSerialForMeter.DeviceName = POINTNAME;

                    while (m_CoolSerialForMeter.StateInfo != "open" && i < 10)
                    {
                        m_CoolSerialForMeter.Open();

                        if (m_CoolSerialForMeter.StateInfo == "open")
                        {
                            m_CoolSerialForMeter.StartUse();

                            MeterData  = m_CoolSerialForMeter.StringData;
                            MeterValue = m_CoolSerialForMeter.DecimalData;
                        }

                        i++;
                    }

                    m_szMeterData = m_CoolSerialForMeter.StringData;
                    m_MeterValue  = m_CoolSerialForMeter.DecimalData;
                    //string  strLog = "串口数据:" + MeterData + " 显示数据:" + MeterValue;
                    //WriteLog(strLog);
                }

                if (UseLED)
                {
                    m_CoolLed            = new CoolLed(LEDPARA);
                    m_CoolLed.DeviceType = LEDTYPE;//LED类型,决定如何处理事务
                    m_CoolLed.DeviceName = POINTNAME;
                    if (m_CoolLed.Open())
                    {
                        //add code here
                    }
                }

                if (UseDisplay)
                {
                    m_CoolDisplay            = new CoolDisplay(DISPLAYPARA);
                    m_CoolDisplay.DeviceType = DISPLAYTYPE;//液晶屏类型,决定如何处理事务
                    m_CoolDisplay.DeviceName = POINTNAME;
                    m_CoolDisplay.Open();
                }

                if (UseRtu)
                {
                    i                    = 0;
                    m_CoolRtu            = new CoolRtu(RTUIP, Int32.Parse(RTUPORT));
                    m_CoolRtu.DeviceName = POINTNAME;
                    //if (m_CoolRtu.Connect2Server())
                    //{
                    //    m_CoolRtu.StartUse();
                    //}
                    while (m_CoolRtu.StateInfo != "open" && i < 10)
                    {
                        m_CoolRtu.Connect2Server();
                        if (m_CoolRtu.StateInfo == "open")
                        {
                            m_CoolRtu.StartUse();
                        }
                        i++;
                    }

                    i = 0;
                    m_CoolRtuForCommand            = new CoolRtu(RTUIP, Int32.Parse(RTUPORT));
                    m_CoolRtuForCommand.DeviceName = POINTNAME;
                    while (m_CoolRtuForCommand.StateInfo != "open" && i < 10)
                    {
                        m_CoolRtuForCommand.Connect2Server();
                        i++;
                    }
                    //if (m_CoolRtuForCommand.Connect2Server())
                    //{
                    //}
                }

                m_bRunning = true;
                m_hThread  = new System.Threading.Thread(new System.Threading.ThreadStart(DataCollectThread));
                m_hThread.Start();
            }
            catch (Exception e)
            {
                WriteLog("StartUse" + e.ToString());
            }
        }
Beispiel #2
0
        //System.IO.TextWriter tw = new System.IO.StreamWriter(m_szRunPath + "\\log\\22_pound.log", true);
        #endregion


        #region constructor

        public ProductPoundRoom()
        {
            //System.IO.TextWriter tw = new System.IO.StreamWriter(m_szRunPath + "\\log\\22_pound.log", true);
            m_POINTID   = "";       //计量点编码
            m_POINTNAME = "";       //计量点名称
            m_POINTTYPE = "";       //计量点称重类型

            m_VIEDOIP   = "";       //硬盘录像机IP
            m_VIEDOPORT = "";       //硬盘录像机端口
            m_VIEDOUSER = "";       //硬盘录像机用户名
            m_VIEDOPWD  = "";       //硬盘录像机密码

            m_MOXAIP = "";          //MOXA卡IP

            m_METERTYPE       = ""; //仪表类型
            m_METERPARA       = ""; //仪表参数
            m_MOXAPORT        = ""; //计量仪表MOXA卡端口
            m_MeterPreData    = 0;  //仪表前一次重量
            m_nMeterStabTimes = 0;  //仪表稳定次数

            m_RTUIP   = "";         //RTUIP
            m_RTUPORT = "";         //RTU端口

            m_PRINTERIP      = "";  //打印服务器IP
            m_PRINTERNAME    = "";  //打印机名称
            m_PRINTTYPECODE  = "";  //打印机类型代码
            m_USEDPAPER      = 0;   //已用纸张量
            m_TOTALPAPAR     = 0;   //打印纸总数量
            m_STATUS         = "";  //计量点状态
            m_ACCEPTTERMINAL = "";  //接管的终端IP

            m_LEDPORT = "";         //电子屏MOXA卡端口
            m_LEDPARA = "";         //电子屏MOXA卡参数
            m_LEDTYPE = "";         //电子屏类型

            m_READERPORT = "";      //读卡器MOXA卡端口
            m_READERPARA = "";      //读卡器MOXA卡参数
            m_READERTYPE = "";      //读卡器类型

            m_DISPLAYPORT = "";     //液晶屏MOXA卡端口
            m_DISPLAYPARA = "";     //液晶屏MOXA卡参数
            m_DISPLAYTYPE = "";     //液晶屏类型

            //使用何种设备标志
            m_bUseMeter   = false; //采集仪表数据
            m_bUseLED     = false; //使用LED
            m_bUseReader  = false; //使用读卡器
            m_bUseDisplay = false; //使用液晶屏
            m_bUseRtu     = false; //使用rtu

            //MOXA
            m_CoolSerialForMeter = null; //仪表
            m_CoolLed            = null; //LED
            m_CoolDisplay        = null; //液晶屏

            //rtu
            m_CoolRtu           = null; //rtu data collect
            m_CoolRtuForCommand = null; //rtu command send

            //线程
            m_hThread  = null;  //线程
            m_bRunning = false; //线程运行开关

            //数据
            m_szMeterData    = "";   //仪表采集数据
            m_szReaderGUID   = "";   //读卡器全球唯一号
            m_szReaderCardNo = "";   //读卡器卡号
            m_szRtuData      = null; //rtu data

            //接管
            m_bSigned = false;

            //播放声音
            m_SoundPlayer = null;

            //硬盘录像机
            m_VideoRecord = null;
            m_VideoHandle = 0;
            m_Channel1    = 0;     //通道1句柄
            m_Channel2    = 0;     //通道2句柄
            m_Channel3    = 0;     //通道3句柄
            m_Channel4    = 0;     //通道4句柄
            m_Channel5    = 0;     //通道5句柄
            m_Channel6    = 0;     //通道6句柄
            m_bTalk       = false; //是否正在对讲
            m_TalkID      = 0;     //对讲句柄
            m_AudioNum    = 1;     //可使用音频数

            m_bSaved   = false;
            m_PreState = false;
            m_CurState = false;
        }