예제 #1
0
        private static void GetSerialInfo(
            out string strSerialName,
            out bool IsHeaderEffect,
            out bool IsTailEffect,
            out int HeaderXType,
            out int TailXType,
            out int HeaderYType,
            out int TailYType)
        {
            strSerialName  = "";
            IsHeaderEffect = false;
            IsTailEffect   = false;
            HeaderXType    = 0;
            TailXType      = 0;
            HeaderYType    = 0;
            TailYType      = 0;

            string    strMathineName = LoginInfo.MachineName;
            DataTable dtSerial       = ExecuteSQL.CallView(134, "", "MachineName='" + strMathineName + "'", "");

            if (dtSerial.Rows.Count > 0)
            {
                DataRow dr = dtSerial.Rows[0];
                //long lWeightDeviceUserTypeID = LBConverter.ToInt64(dr["WeightDeviceUserTypeID"]);
                strSerialName  = dr["SerialName"].ToString();
                IsHeaderEffect = LBConverter.ToBoolean(dr["IsHeaderEffect"]);
                IsTailEffect   = LBConverter.ToBoolean(dr["IsTailEffect"]);
                HeaderXType    = LBConverter.ToInt32(dr["HeaderXType"]);
                TailXType      = LBConverter.ToInt32(dr["TailXType"]);
                HeaderYType    = LBConverter.ToInt32(dr["HeaderYType"]);
                TailYType      = LBConverter.ToInt32(dr["TailYType"]);
            }
        }
예제 #2
0
        public static void StartSerial(enCardType cardType)
        {
            //bool bolIsUse = false;//是否启用读卡器或者写卡器
            try
            {
                DataTable dtDesc = ExecuteSQL.CallView(140, "", "MachineName='" + LoginInfo.MachineName + "'", "");
                if (dtDesc.Rows.Count > 0)
                {
                    if (cardType == enCardType.ReadCard)
                    {
                        _Com          = dtDesc.Rows[0]["ReadCardSerialCOM"].ToString().TrimEnd();
                        IsUseReadCard = LBConverter.ToBoolean(dtDesc.Rows[0]["UseReadCard"]);
                        _IsUseNet     = LBConverter.ToInt32(dtDesc.Rows[0]["ConnectType"].ToString().TrimEnd()) == 1 ? true : false;
                        _NetIPAddress = dtDesc.Rows[0]["IPAddress"].ToString().TrimEnd();
                        _NetPort      = LBConverter.ToInt32(dtDesc.Rows[0]["IPPort"].ToString().TrimEnd());
                    }
                    else
                    {
                        _Com          = dtDesc.Rows[0]["WriteCardSerialCOM"].ToString().TrimEnd();
                        IsUseReadCard = LBConverter.ToBoolean(dtDesc.Rows[0]["UseWriteCard"]);
                    }
                    powerDbm = LBConverter.ToByte(dtDesc.Rows[0]["ReadCardBaud"]);
                }

                //if (mTimer == null)
                //{
                //    mTimer = new System.Windows.Forms.Timer();
                //    mTimer.Interval = 500;
                //    mTimer.Tick += MTimer_Tick;
                //    mTimer.Enabled = true;
                //}

                if (mTimerVerify == null)
                {
                    mTimerVerify          = new System.Windows.Forms.Timer();
                    mTimerVerify.Interval = 2000;
                    mTimerVerify.Tick    += mTimerVerify_Tick;
                    mTimerVerify.Enabled  = true;
                }
            }
            catch (Exception ex)
            {
                LBErrorLog.InsertFileLog("StartSerial:" + ex.Message);
            }

            try
            {
                if (COMIsOpen)
                {
                    ClosePort();
                }
                if (IsUseReadCard && !COMIsOpen)
                {
                    COMIsOpen = OpenPort();
                }

                //if (IsUseReadCard)
                //{
                //    if (mThread == null)
                //    {
                //        mThread = new Thread(ReadCardAction);
                //        mThread.Start();
                //    }
                //}
            }
            catch (Exception ex)
            {
            }
        }