public XmlElement GetTag(string ipAddress, string port) { try { _reader = new clsReader(); _reader.InitOnNetwork(ipAddress,Convert.ToInt16(port)); _reader.Connect(); if (_reader.IsConnected) { if (!_reader.Login("alien", "password")) { throw new Exception("Cannot Login..."); } string result = _reader.TagList; if (result != null && result.Length > 0) { _result = GetXML(result); } _reader.Disconnect(); } else { throw new Exception("Cannot Connect..."); } } catch (Exception ex) { _result = GetExceptionXML(ex.ToString()); } return _result; }
private void btnConnect_Click(object sender, System.EventArgs e) { String result; string tempstr; this.Cursor = Cursors.WaitCursor; try { if (meReaderInterface == ComInterface.enumTCPIP) { mReader.InitOnNetwork(textBox1.Text, Convert.ToInt32(PortUD.Value)); } DisplayText("\r\nConnecting to the reader...\r\n"); label2.Text = "正在连接......"; this.Cursor = Cursors.WaitCursor; result = mReader.Connect(); if (!mReader.IsConnected) { textReaderTalk.AppendText("\r\nCan't connect\r\n"); } else { if (meReaderInterface == ComInterface.enumTCPIP) { DisplayText("\r\nLogging in...\r\n"); this.Cursor = Cursors.WaitCursor; if (!mReader.Login(this.UserName.Trim(), this.Password.Trim())) //returns result synchronously { DisplayText("\r\nLogin failed! Calling Disconnect()...\r\n"); mReader.Disconnect(); label2.Text = "连接失败!"; return; } DisplayText("\r\nLogged in - OK!\r\n"); tempstr = mReader.SendReceive("set function=programmer", false).Trim(); //设置Reader为编程状态 label2.Text = "登陆成功!编程状态"; } DisplayText(result); ManageGUI(true); textReaderTalk.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Cursor = Cursors.Default; }
//构造方法初始化读写器信息 public MyAlienReader() { reader = new clsReader(true); reader.InitOnNetwork("192.168.1.100", 23); result = reader.Connect(); allResult = new HashSet<string>(); if (reader.IsConnected) { reader.Login("alien", "password"); reader.AutoMode = "On"; } }
public void connect_reader(object sender, System.EventArgs e) { String result; try { if (meReaderInterface == ComInterface.enumTCPIP) { mReader.InitOnNetwork("127.0.0.1", 22); } else { mReader.InitOnCom(); } txtLogger.Info("Start connect to reader: {}:{}", m_reader_ip, m_reader_port); result = mReader.Connect(); if (mReader.IsConnected) { if (meReaderInterface == ComInterface.enumTCPIP) { if (!mReader.Login("alien", "password")) { txtLogger.Error("connect to reader: {}:{} failed with alien and password", m_reader_ip, m_reader_port); mReader.Disconnect(); return; } } txtLogger.Info("connect to reader: {}:{}", m_reader_ip, m_reader_port); // to make it faster and not to lose any tag mReader.AutoMode = "On"; // TODO: 其他参数设置 } } catch (Exception ex) { txtLogger.Error("Exception in btnConnect_Click(): " + ex.Message); } }
private void MainWindow_Load(object sender, EventArgs e) { //Fitting Screen this.Location = new Point(0, 0); this.Size = Screen.PrimaryScreen.WorkingArea.Size; //Fitting Stream -> PictureBoxes this.Controls.Add(input_cam); this.input_cam.SizeMode = PictureBoxSizeMode.StretchImage; this.Controls.Add(output_cam); this.output_cam.SizeMode = PictureBoxSizeMode.StretchImage; this.logoPB.SizeMode = PictureBoxSizeMode.StretchImage; /*RFID Reader Inits*/ mReader = new clsReader(); mReaderInterface = ComInterface.enumTCPIP; mReader.Disconnect(); try { if (mReaderInterface == ComInterface.enumTCPIP) { mReader.InitOnNetwork("192.168.1.100", 23); } else { mReader.InitOnCom(); } string result = mReader.Connect(); if (mReader.IsConnected) { if (mReaderInterface == ComInterface.enumTCPIP) { this.Cursor = Cursors.Arrow; if (!mReader.Login("alien", "password")) { mReader.Disconnect(); return; } } mReader.AutoMode = "On"; } //Stream Inits input_mjpeg = new MjpegDecoder(); input_mjpeg.FrameReady += input_mjpeg_frameReady; output_mjpeg = new MjpegDecoder(); output_mjpeg.FrameReady += output_mjpeg_frameReady; add_cam(); //Timers antennaTimer1.Enabled = true; antennaTimer2.Enabled = true; } catch { inputInfoPanel.BackColor = Color.Red; } //Motion Detection Variables Inits fic = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo item in fic) { metroComboBox1.Items.Add(item.Name); } metroComboBox1.SelectedIndex = 0; detector = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionBorderHighlighting()); detector_ks = 0; // Init value }