Пример #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
        private static void AppendString(byte[] myArray)
        {
            if (_comm.ReceivedBytesThreshold == BUFF_HEX_SIZE)
            {
                string strValue = Convert.ToString(myArray[6], 2);

                if (strValue.Length >= 4)
                {
                    byte X0 = LBConverter.ToByte(strValue.Substring(3, 1));
                    byte X1 = LBConverter.ToByte(strValue.Substring(2, 1));
                    byte X2 = LBConverter.ToByte(strValue.Substring(1, 1));
                    byte X3 = LBConverter.ToByte(strValue.Substring(0, 1));

                    if (HeaderXType == 0 && X0 == 0)
                    {
                        HeaderClosed = true;
                    }
                    else if (HeaderXType == 1 && X1 == 0)
                    {
                        HeaderClosed = true;
                    }
                    else if (HeaderXType == 2 && X2 == 0)
                    {
                        HeaderClosed = true;
                    }
                    else if (HeaderXType == 3 && X3 == 0)
                    {
                        HeaderClosed = true;
                    }
                    else
                    {
                        HeaderClosed = false;
                    }

                    if (TailXType == 0 && X0 == 0)
                    {
                        TailClosed = true;
                    }
                    else if (TailXType == 1 && X1 == 0)
                    {
                        TailClosed = true;
                    }
                    else if (TailXType == 2 && X2 == 0)
                    {
                        TailClosed = true;
                    }
                    else if (TailXType == 3 && X3 == 0)
                    {
                        TailClosed = true;
                    }
                    else
                    {
                        TailClosed = false;
                    }
                }
            }
        }
Пример #3
0
        private static void GetSerialInfo(
            out string strSerialName,
            out int DeviceBoTeLv,
            out int DeviceZhenChuLiFangShi,
            out int DeviceShuJuWei,
            out int DeviceZhenQiShiBiaoShi,
            out int iWeightDeviceType)
        {
            strSerialName          = "";
            DeviceBoTeLv           = 0;
            DeviceZhenChuLiFangShi = 0;
            DeviceShuJuWei         = 0;
            DeviceZhenQiShiBiaoShi = 0;
            iWeightDeviceType      = 0;

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

            if (dtSerial.Rows.Count > 0)
            {
                DataRow dr = dtSerial.Rows[0];
                long    lWeightDeviceUserTypeID = LBConverter.ToInt64(dr["WeightDeviceUserTypeID"]);
                strSerialName     = dr["SerialName"].ToString();
                iWeightDeviceType = LBConverter.ToInt32(dr["WeightDeviceType"]);

                if (iWeightDeviceType == 0)//自定义
                {
                    if (lWeightDeviceUserTypeID > 0)
                    {
                        DataTable dtUserConfig = ExecuteSQL.CallView(119, "", "WeightDeviceUserTypeID=" + lWeightDeviceUserTypeID, "");

                        if (dtUserConfig.Rows.Count > 0)
                        {
                            DataRow drUserConfig = dtUserConfig.Rows[0];
                            DeviceBoTeLv           = LBConverter.ToInt32(drUserConfig["DeviceBoTeLv"]);
                            DeviceShuJuWei         = LBConverter.ToInt32(drUserConfig["DeviceShuJuWei"]);
                            DeviceZhenChuLiFangShi = LBConverter.ToInt32(drUserConfig["DeviceZhenChuLiFangShi"]);
                            DeviceZhenQiShiBiaoShi = LBConverter.ToInt32(drUserConfig["DeviceZhenQiShiBiaoShi"]);
                        }
                    }
                }
                else
                {
                    DataTable dtSysSerial = ExecuteSQL.CallView(118, "", "WeightDeviceType=" + iWeightDeviceType, "");
                    if (dtSysSerial.Rows.Count > 0)
                    {
                        DataRow drSerial = dtSysSerial.Rows[0];
                        DeviceBoTeLv           = LBConverter.ToInt32(drSerial["DeviceBoTeLv"]);
                        DeviceShuJuWei         = LBConverter.ToInt32(drSerial["DeviceShuJuWei"]);
                        DeviceZhenChuLiFangShi = LBConverter.ToInt32(drSerial["DeviceZhenChuLiFangShi"]);
                        DeviceZhenQiShiBiaoShi = LBConverter.ToInt32(drSerial["DeviceZhenQiShiBiaoShi"]);
                    }
                }
            }
        }
Пример #4
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)
            {
            }
        }