Пример #1
0
        public FormScanConfig(IRP1.Reader reader)
        {
            InitializeComponent();
            this.reader = reader;

            btnQuery_Click(null, EventArgs.Empty);
        }
Пример #2
0
 // 建立连接
 private void btnConn_Click(object sender, EventArgs e)
 {
     if (reader.Connect())
     {
         changeCtrlEnable("conn");
         //注册接收读写器消息事件
         reader.OnMessageNotificationReceived += new Invengo.NetAPI.Core.MessageNotificationReceivedHandle(reader_OnMessageNotificationReceived);
         lblMsg.Text = "Connection Successful!";
     }
     else
     {
         reader = new IRP1.Reader("Reader1", "RS232", this.comboBox1.Text + ",115200");
         if (reader.Connect())
         {
             changeCtrlEnable("conn");
             //注册接收读写器消息事件
             reader.OnMessageNotificationReceived += new Invengo.NetAPI.Core.MessageNotificationReceivedHandle(reader_OnMessageNotificationReceived);
             lblMsg.Text = "Connection Successful!";
         }
         else
         {
             lblMsg.Text = "Connection Failed!";
             MessageBox.Show("Failed to create the connection.");
         }
     }
 }
Пример #3
0
        void listener_OnClientConn(Socket socket, String pVer)
        {
            if (pVer == "IRP1")
            {
                IRP1.Reader reader = new IRP1.Reader(socket);

                if (reader.Connect())
                {
                    #region 激活天线
                    reader.Send(new IRP1.SysConfig_500(0x02, 0x01, new Byte[] { 0x01 }), 200);
                    #endregion
                    if (reader.IsConnected)
                    {
                        MyReader r = new MyReader();
                        r.reader = reader;
                        if (r.reader.ProtocolVersion == "IRP1")
                        {
                            r.ScanMessage = new IRP1.ReadTag(IRP1.ReadTag.ReadMemoryBank.EPC_6C);
                            r.StopMessage = new IRP1.PowerOff();//XC-RF502E-F6G
                        }
                        reader.OnMessageNotificationReceived += new MessageNotificationReceivedHandle(r_OnMessageNotificationReceived);
                        ReaderList.Add(r);
                        if (OnReaderClientConn != null)
                        {
                            OnReaderClientConn(r, EventArgs.Empty);
                        }
                    }
                }
            }
        }
Пример #4
0
 void myReaders_OnReaderNotificationMsg(IRP1.Reader reader, NotificationMessage nMsg)
 {
     if (nMsg != null)
     {
         displayDataGridView(nMsg.ReaderName, nMsg.TagType, nMsg.EPC, nMsg.TID, nMsg.Userdata, nMsg.Antenna, nMsg.RSSI, nMsg.ReadTime, nMsg.Reserved);
     }
 }
Пример #5
0
 public FormReaderConfig(IRP1.Reader reader)
 {
     InitializeComponent();
     this.reader = reader;
     this.cbkListenNet.Checked = RFIDRead.isTryReconnNet;
     this.tryReconnNetTimeSpan = RFIDRead.tryReconnNetTimeSpan;
 }
Пример #6
0
        public FormScanConfig(IRP1.Reader reader)
        {
            InitializeComponent();

            this.reader = reader;

            if (msg.Antenna == 129)
            {
                a1.Checked = true;
            }
            if (msg.Antenna == 130)
            {
                a2.Checked = true;
            }
            if (msg.Antenna == 131)
            {
                a1.Checked = true;
                a2.Checked = true;
            }
            this.rbLoop.Checked   = msg.IsLoop;
            this.rbSingle.Checked = !msg.IsLoop;

            this.numQ.Value = msg.Q;

            btnQuery_Click(null, EventArgs.Empty);
        }
Пример #7
0
 public FormScanConfig(IRP1.Reader reader)
 {
     InitializeComponent();
     this.reader            = reader;
     cbReadMB.SelectedIndex = 0;
     a1.Checked             = true;
     btnQuery_Click(null, EventArgs.Empty);
 }
Пример #8
0
 public FormGPIO(IRP1.Reader reader, IRP1.ReadTag scanMsg)
 {
     InitializeComponent();
     this.reader  = reader;
     this.scanMsg = scanMsg;
     if (cmbox1.Items.Count > 0)
     {
         cmbox1.SelectedIndex = 0;
     }
 }
Пример #9
0
        void myReaders_OnReaderErrorMsg(IRP1.Reader reader, string errString)
        {
            object[] myArray = new object[1];
            string   str     = errString + "\r\n";

            if (reader != null)
            {
                str = reader.ReaderName + ": " + str;
            }
            myArray[0] = str;
            txtMsg.BeginInvoke(new DisplayReaderErrorMsgDelegate(DisplayReaderErrorMsgMethod), myArray);
        }
Пример #10
0
        private void btn_Connect_Click(object sender, EventArgs e)
        {
            reader = new IRP1.Reader("Reader1", "TCPIP_Client", tbIPconnect.Text + ":7086"); //TCP
            msg    = new IRP1.ReadTag(IRP1.ReadTag.ReadMemoryBank.EPC_6C);                   //

            {
                // Added MQTT COde
                string BrokerAddress = "localhost";
                Topic = txtTopic.Text;
                if (Topic == "")
                {
                    Topic = "rfidX";
                }
                client   = new MqttClient(BrokerAddress);
                clientId = Guid.NewGuid().ToString();
                client.Connect(clientId);
                // subscribe to the topic with QoS 2
                //client.Subscribe(new string[] { Topic }, new byte[] { 2 });   // we need arrays as parameters because we can subscribe to different topics with one call
                //return; // For Debugging



                if (reader.Connect())
                {
                    reader.OnMessageNotificationReceived += new Invengo.NetAPI.Core.MessageNotificationReceivedHandle(reader_OnMessageNotificationReceived);
                    lbl_msg.Text = "Conn successful";

                    btn_Disconnect.Enabled = true;
                    btn_Connect.Enabled    = false;
                    btn_ReadEPC.Enabled    = true;
                    changeCtrlEnable("conn");
                    //btnQuery.PerformClick();
                    //btnModelSN.PerformClick();
                    //btn_Query.PerformClick();
                    //btnAntQuery.PerformClick();
                    //btnQueryRF.PerformClick();
                }
                else
                {
                    lbl_msg.Text = "Conn failed";
                    MessageBox.Show("Conn failed");
                }
            }
        }
Пример #11
0
        public FormMain()
        {
            try
            {
                mycon.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show("You should link to the database.");
            }

            InitializeComponent();

            //traversing all possible serial ports, use the first one
            string[] serialPort = SerialPort.GetPortNames();

            //add the available ports to selectButton
            foreach (var port in serialPort)
            {
                comboBox1.Items.Add(port);
            }

            reader = new IRP1.Reader("Reader1", "RS232", serialPort[0] + ",115200");

            this.FormClosed += new FormClosedEventHandler(FormMain_FormClosed);

            if (port == null)
            {
                //COM4为Arduino使用的串口号,需根据实际情况调整
                //port = new SerialPort("COM4", 9600);
                //port.Open();
            }

            myDt.Columns.Add("EPC");
            myDt.Columns.Add("barcode");
            myDt.Columns.Add("Count");
            dataGridView1.DataSource            = myDt;
            dataGridView1.Columns[0].HeaderText = "EPC";
            dataGridView1.Columns[1].HeaderText = "Barcode";
            dataGridView1.Columns[2].HeaderText = "Count";

            IRP1.Reader.OnApiException += new Core.ApiExceptionHandle(Reader_OnApiException);
        }
Пример #12
0
        public static void InitRFID()
        {
            MCP.Config.Configuration conf = new MCP.Config.Configuration();
            conf.Load("Config.xml");
            string RFIDConnetIP = conf.Attributes["RFIDConnetIP"];
            string Antenna      = conf.Attributes["Antenna"];
            string Q            = conf.Attributes["Q"];
            string IsLoop       = conf.Attributes["IsLoop"];

            isTryReconnNet       = conf.Attributes["isTryReconnNet"] == "1" ? true : false;
            tryReconnNetTimeSpan = int.Parse(conf.Attributes["tryReconnNetTimeSpan"]);
            reader = new IRP1.Reader("Reader1", "TCPIP_Client", RFIDConnetIP);
            IRP1.Reader.OnApiException += new Core.ApiExceptionHandle(Reader_OnApiException);

            scanMsg         = new IRP1.ReadTag(IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C);
            scanMsg.Q       = byte.Parse(Q);
            scanMsg.IsLoop  = ((IsLoop == "1") ? true : false);
            scanMsg.Antenna = byte.Parse(Antenna);
        }
Пример #13
0
        public MyReader(String readerName)//TCPIP_Client
        {
            _reader = new IRP1.Reader(readerName);
            if (_reader.ProtocolVersion == "IRP1")
            {
                XmlNode node = Common.sysit_xml.DocumentElement.SelectSingleNode("Reader[@Name='" + _reader.ReaderName + "']");
                XmlNode sn   = node.SelectSingleNode("ScanMessage");
                #region ScanMessage
                IRP1.ReadTag.ReadMemoryBank rmb = (IRP1.ReadTag.ReadMemoryBank)
                                                  Enum.Parse(typeof(IRP1.ReadTag.ReadMemoryBank), sn.Attributes["ReadMemoryBank"].Value);
                scanMsgParam.readMemoryBank = rmb;
                int readtime = int.Parse(sn.SelectSingleNode("ReadTime").InnerText);
                int stoptime = int.Parse(sn.SelectSingleNode("StopTime").InnerText);
                scanMsgParam.readtime = readtime;
                scanMsgParam.stoptime = stoptime;
                string readertype = "800";
                if (_reader.ModelNumber.IndexOf("502E") != -1 || _reader.ModelNumber == "XC-RF811")
                {
                    readertype = "500";
                }
                if (readtime > 0 || stoptime > 0)
                {
                    ScanMessage = new IRP1.ReadTag(rmb, readtime, stoptime);
                }
                else
                {
                    ScanMessage = new IRP1.ReadTag(rmb);
                }

                IRP1.ReadTag rt = (IRP1.ReadTag)ScanMessage;
                switch (rmb)
                {
                case IRP1.ReadTag.ReadMemoryBank.EPC_6C:
                case IRP1.ReadTag.ReadMemoryBank.EPC_6C_ID_6B:
                case IRP1.ReadTag.ReadMemoryBank.EPC_PC_6C:
                case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C:
                case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C_ID_UserData_6B:
                case IRP1.ReadTag.ReadMemoryBank.TID_6C:
                case IRP1.ReadTag.ReadMemoryBank.TID_6C_ID_6B:
                {
                    string[] ps = sn.SelectSingleNode("Param").InnerText.Split(',');
                    scanMsgParam.antennaIndex = byte.Parse(ps[0]);
                    rt.Antenna          = getAntenna(ps[0], readertype);
                    scanMsgParam.q      = rt.Q = byte.Parse(ps[1]);
                    scanMsgParam.isLoop = rt.IsLoop = ((ps[2] == "1") ? true : false);
                }
                break;

                case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_6C_2:
                {
                    string[] ps = sn.SelectSingleNode("Param").InnerText.Split(',');
                    scanMsgParam.antennaIndex = byte.Parse(ps[0]);
                    rt.Antenna                  = getAntenna(ps[0], readertype);
                    scanMsgParam.q              = rt.Q = byte.Parse(ps[1]);
                    scanMsgParam.isLoop         = rt.IsLoop = ((ps[2] == "1") ? true : false);
                    scanMsgParam.tidLen         = rt.TidLen = byte.Parse(ps[3]);
                    scanMsgParam.userdataPtr_6C = rt.UserDataPtr_6C = uint.Parse(ps[4]);
                    scanMsgParam.userdataLen_6C = rt.UserDataLen_6C = byte.Parse(ps[5]);
                }
                break;

                case IRP1.ReadTag.ReadMemoryBank.EPC_TID_UserData_Reserved_6C_ID_UserData_6B:
                {
                    string[] ps = sn.SelectSingleNode("Param").InnerText.Split(',');
                    scanMsgParam.antennaIndex = byte.Parse(ps[0]);
                    rt.Antenna                  = getAntenna(ps[0], readertype);
                    scanMsgParam.q              = rt.Q = byte.Parse(ps[1]);
                    scanMsgParam.isLoop         = rt.IsLoop = ((ps[2] == "1") ? true : false);
                    scanMsgParam.tidLen         = rt.TidLen = byte.Parse(ps[3]);
                    scanMsgParam.userdataPtr_6C = rt.UserDataPtr_6C = uint.Parse(ps[4]);
                    scanMsgParam.userdataLen_6C = rt.UserDataLen_6C = byte.Parse(ps[5]);
                    scanMsgParam.userdataPtr_6B = rt.UserDataPtr_6B = byte.Parse(ps[6]);
                    scanMsgParam.userdataLen_6B = rt.UserDataLen_6B = byte.Parse(ps[7]);
                    scanMsgParam.reservedLen    = rt.ReservedLen = byte.Parse(ps[8]);
                    scanMsgParam.pwd            = rt.AccessPwd = Util.ConvertHexStringToByteArray(ps[9]);
                    scanMsgParam.readTimes_6C   = rt.ReadTimes_6C = byte.Parse(ps[10]);
                    scanMsgParam.readTimes_6B   = rt.ReadTimes_6B = byte.Parse(ps[11]);
                }
                break;

                case IRP1.ReadTag.ReadMemoryBank.ID_6B:
                case IRP1.ReadTag.ReadMemoryBank.ID_UserData_6B:
                {
                    string[] ps = sn.SelectSingleNode("Param").InnerText.Split(',');
                    scanMsgParam.antennaIndex = byte.Parse(ps[0]);
                    rt.Antenna          = getAntenna(ps[0], readertype);
                    scanMsgParam.isLoop = rt.IsLoop = ((ps[1] == "1") ? true : false);
                }
                break;
                }
                #endregion
                #region StopMessage
                StopMessage = new IRP1.PowerOff();
                #endregion
            }
        }
Пример #14
0
 public FormReaderConfig(IRP1.Reader reader)
 {
     InitializeComponent();
     this.reader = reader;
 }
Пример #15
0
 void myReaders_OnTagAlarm(IRP1.Reader reader, EventArgs arg)
 {
     Console.Beep(4500, 1);
 }