示例#1
0
        /// <summary>
        ///     得到通讯参数
        /// </summary>
        /// <param name="strEquipment"></param>
        /// <returns></returns>
        public STRUCT_CMT_INFO GetCmtPara(string strEquipment)
        {
            var tCmtInfo = new STRUCT_CMT_INFO
            {
                m_nType = ConverToInt32(m_oIniFile.ReadContentValueFromIni(strEquipment, "Type", m_strCmtIniPath))
            };

            switch (tCmtInfo.m_nType)
            {
            case 0:
                tCmtInfo.m_nSerialBaudRate =
                    ConverToInt32(m_oIniFile.ReadContentValueFromIni(strEquipment, "Baud", m_strCmtIniPath));
                tCmtInfo.m_nSerialDateBits =
                    ConverToInt32(m_oIniFile.ReadContentValueFromIni(strEquipment, "Date", m_strCmtIniPath));
                tCmtInfo.m_strSerialParity =
                    m_oIniFile.ReadContentValueFromIni(strEquipment, "Parity", m_strCmtIniPath);
                tCmtInfo.m_strSerialPortNum =
                    m_oIniFile.ReadContentValueFromIni(strEquipment, "COM", m_strCmtIniPath);
                tCmtInfo.m_strSerialStopBits =
                    m_oIniFile.ReadContentValueFromIni(strEquipment, "Stop", m_strCmtIniPath);
                break;

            case 1:
                tCmtInfo.m_nStcpPort =
                    Convert.ToInt32(m_oIniFile.ReadContentValueFromIni(strEquipment, "Port", m_strCmtIniPath));

                tCmtInfo.m_strStcpAddress =
                    m_oIniFile.ReadContentValueFromIni(strEquipment, "Address", m_strCmtIniPath);
                break;
            }

            return(tCmtInfo);
        }
示例#2
0
        /// <summary>
        ///     保存通讯参数到Ini
        /// </summary>
        /// <param name="strEquipment"></param>
        /// <param name="tCmtInfo"></param>
        public void SaveCmtParaToIni(string strEquipment, STRUCT_CMT_INFO tCmtInfo)
        {
            m_oIniFile.WriteContentValueToIni(strEquipment, @"Type", tCmtInfo.m_nType.ToString(),
                                              m_strCmtIniPath);
            switch (tCmtInfo.m_nType)
            {
            case 0:
                m_oIniFile.WriteContentValueToIni(strEquipment, @"COM", tCmtInfo.m_strSerialPortNum,
                                                  m_strCmtIniPath);
                m_oIniFile.WriteContentValueToIni(strEquipment, @"Baud", tCmtInfo.m_nSerialBaudRate.ToString(),
                                                  m_strCmtIniPath);
                m_oIniFile.WriteContentValueToIni(strEquipment, @"Date", tCmtInfo.m_nSerialDateBits.ToString(),
                                                  m_strCmtIniPath);
                m_oIniFile.WriteContentValueToIni(strEquipment, @"Stop", tCmtInfo.m_strSerialStopBits,
                                                  m_strCmtIniPath);
                m_oIniFile.WriteContentValueToIni(strEquipment, @"Parity", tCmtInfo.m_strSerialParity,
                                                  m_strCmtIniPath);
                break;

            case 1:
                m_oIniFile.WriteContentValueToIni(strEquipment, @"Address", tCmtInfo.m_strStcpAddress,
                                                  m_strCmtIniPath);
                m_oIniFile.WriteContentValueToIni(strEquipment, @"Port", tCmtInfo.m_nStcpPort.ToString(),
                                                  m_strCmtIniPath);
                break;
            }
        }
示例#3
0
        /// <summary>
        ///     创造通讯抽象类工厂
        /// </summary>
        /// <param name="tCmtInfo"></param>
        /// <returns></returns>
        private CCmtFactoryAbs CreatCmtFactory(STRUCT_CMT_INFO tCmtInfo)
        {
            CCmtFactoryAbs oCmtFactory = null;

            switch (tCmtInfo.m_nType)
            {
            case 0:
                //电子秤通讯使用的是串口
                oCmtFactory = new CSerialPortFactory(tCmtInfo.m_strSerialPortNum, tCmtInfo.m_nSerialBaudRate,
                                                     tCmtInfo.m_nSerialDateBits,
                                                     tCmtInfo.m_strSerialParity, tCmtInfo.m_strSerialStopBits);
                break;

            case 1:
                oCmtFactory = new CTcpClientFactory(tCmtInfo.m_strStcpAddress, tCmtInfo.m_nStcpPort);
                break;
            }

            return(oCmtFactory);
        }
示例#4
0
        /// <summary>
        ///     创建操作视觉的对象
        /// </summary>
        /// <param name="tCmtInfo"></param>
        public void CreatVision(STRUCT_CMT_INFO tCmtInfo)
        {
            var oCmtFactory = CreatCmtFactory(tCmtInfo);

            m_oVisionAbs = new CAnsonVision(oCmtFactory.Creat());
        }
示例#5
0
        private DELEGATE_MSG m_delegateMsgScanner; //扫描枪

        #endregion

        #region 成员函数

        /// <summary>
        ///     创造扫码枪
        /// </summary>
        /// <param name="tCmtInfo"></param>
        public void CreatScanner(STRUCT_CMT_INFO tCmtInfo)
        {
            var oCmtFactory = CreatCmtFactory(tCmtInfo);

            m_oScannerAbs = new CCognexScanner(oCmtFactory.Creat());
        }
示例#6
0
        private DELEGATE_MSG m_delegateMsgBalance; //电子秤

        #endregion

        #region 成员函数

        /// <summary>
        ///     创造电子秤
        /// </summary>
        /// <param name="tCmtInfo"></param>
        public void CreatBalance(STRUCT_CMT_INFO tCmtInfo)
        {
            var oCmtFactory = CreatCmtFactory(tCmtInfo);

            m_oBalanceAbs = new CSartorius(oCmtFactory.Creat());
        }