예제 #1
0
        /// <summary>
        /// 初始化外接设备
        /// </summary>
        private void InitHardware()
        {
            try
            {
                bool success = false;

                // 初始化-电子秤
                if (IsUseWeight)
                {
                    this.WbMinWeight  = commonDAO.GetAppletConfigDecimal("电子秤最小重量");
                    this.BarrelWeight = commonDAO.GetAppletConfigDecimal("人工样桶重量");

                    Hardwarer.Wber.OnStatusChange += new WB.XiangPing.Balance.XiangPing_Balance.StatusChangeHandler(wber_OnStatusChange);
                    Hardwarer.Wber.OnSteadyChange += new WB.XiangPing.Balance.XiangPing_Balance.SteadyChangeEventHandler(wber_OnSteadyChange);
                    Hardwarer.Wber.OnWeightChange += new WB.XiangPing.Balance.XiangPing_Balance.WeightChangeEventHandler(wber_OnWeightChange);

                    success             = Hardwarer.Wber.OpenCom(commonDAO.GetAppletConfigInt32("电子秤串口"), commonDAO.GetAppletConfigInt32("电子秤波特率"), commonDAO.GetAppletConfigInt32("电子秤数据位"), commonDAO.GetAppletConfigInt32("电子秤停止位"));
                    SelfVars.WeightOpen = success;
                }

                timer1.Enabled = true;
            }
            catch (Exception ex)
            {
                Log4Neter.Error("设备初始化", ex);
            }
        }
예제 #2
0
        /// <summary>
        /// 初始化外接设备
        /// </summary>
        private void InitHardware()
        {
            try
            {
                bool success = false;
                Hardwarer.ReadRwer.OnStatusChange += new HFReaderRwer.StatusChangeHandler(Rwer_OnStatusChange);
                Rwer_OnStatusChange(Hardwarer.ReadRwer.Status);
                if (!SelfVars.RfReadOpen)
                {
                    // 初始化-读卡器
                    success             = Hardwarer.ReadRwer.OpenNetPort(commonDAO.GetAppletConfigString("读卡器IP"), commonDAO.GetAppletConfigInt32("读卡器端口"));
                    SelfVars.RfReadOpen = success;
                }
                // 初始化-电子天平
                if (IsUseWeight)
                {
                    this.WbMinWeight = commonDAO.GetAppletConfigDecimal("电子天平最小重量");

                    Hardwarer.Wber_min.OnStatusChange += new WB.XiangPing.Balance.XiangPing_Balance.StatusChangeHandler(Wber_OnStatusChange);
                    Hardwarer.Wber_min.OnSteadyChange += new WB.XiangPing.Balance.XiangPing_Balance.SteadyChangeEventHandler(Wber_OnSteadyChange);
                    Hardwarer.Wber_min.OnWeightChange += new WB.XiangPing.Balance.XiangPing_Balance.WeightChangeEventHandler(wber_OnWeightChange);

                    if (!SelfVars.WeightMinOpen)
                    {
                        success = Hardwarer.Wber_min.OpenCom(commonDAO.GetAppletConfigInt32("电子天平串口"), commonDAO.GetAppletConfigInt32("电子天平波特率"), commonDAO.GetAppletConfigInt32("电子天平数据位"), commonDAO.GetAppletConfigInt32("电子天平停止位"));
                        SelfVars.WeightMinOpen = success;
                    }
                }
            }
            catch (Exception ex)
            {
                Log4Neter.Error("设备初始化", ex);
            }
        }