/*
         #########################
         # ANT0 ######## ANT2 ####
         #### ANT1 ######## ANT3 #
         #########################
         */

        /*****************
        ** CORE METHODS **
        *****************/

        // Set up myReader, mySource and mySource2.
        void Initialise()
        {
            myReader.Connect(CAENRFIDPort.CAENRFID_TCP, readerIP);
            mySource = myReader.GetSource("Source_0");
            if (ant0)
            {
                mySource.AddReadPoint("Ant0");
            }
            if (ant1)
            {
                mySource.AddReadPoint("Ant1");
            }
            if (ant2)
            {
                mySource.AddReadPoint("Ant2");
            }
            if (ant3)
            {
                mySource.AddReadPoint("Ant3");
            }
        }
Beispiel #2
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            this.InformationStatusToolStripStatusLabel.Text = "connecting ...";

            try
            {
                Application.DoEvents();
                MyReader = null;
                GC.Collect();
                MyReader = new CAENRFIDReader();
                MyReader.Connect(CAENRFIDPort.CAENRFID_TCP, this.IPtextBox1.Text);
                CAENRFIDReaderInfo info = MyReader.GetReaderInfo();
                MyReader.GetFirmwareRelease();
                MyReader.SetProtocol(CAENRFIDProtocol.CAENRFID_EPC_C1G2);
                this.status = true;
            }
            catch
            {
                this.status = false;
            }

            if (this.status)
            {
                IPtextBox1.Enabled = false;
                buttonConnect.Enabled = false;
                this.InformationStatusToolStripStatusLabel.Text = "connection successful!";
            }
            else
            {
                try
                {
                    MyReader.Disconnect();
                }
                catch
                {
                }

                this.InformationStatusToolStripStatusLabel.Text = "CONNECTION REFUSED!!!";
            }
        }
Beispiel #3
0
        public static M3ClientInitializationStatus Init()
        {
            //Берём из реестра данные о соединении и сборке
            configuration = new ClientConfiguration();
            //Сохраняем в реестре новую версию сборки
            configuration.Build = ClientConfiguration.DefaultBuild;
            configuration.Save();
            //Интернационализация
            i8n.Init();
            i8n.strings.SetLanguage(configuration.Language);

            web = new RfidWebClient(configuration);

            try
            {
                reader = new CAENRFIDReader();
                reader.Connect(CAENRFIDPort.CAENRFID_RS232, "MOC1");
                System.Threading.Thread.Sleep(500);
                M3Client.source = M3Client.reader.GetSources()[0];
            }
            catch (CAENRFIDException e)
            {
                return M3ClientInitializationStatus.ReaderNotReady;
            }

            if (configuration.Server == String.Empty || configuration.DeviceKey == String.Empty)
            {
                return M3ClientInitializationStatus.ClientConfigurationMissing;
            }

            return M3ClientInitializationStatus.Ok;
        }
Beispiel #4
0
        /*****************
        ** CORE METHODS **
        *****************/

        // Set up myReader, mySource and mySource2.
        void Initialise()
        {
            myReader.Connect(CAENRFIDPort.CAENRFID_RS232, readerPort);
            mySource  = myReader.GetSource("Source_0");
            mySource2 = myReader.GetSource("Source_1");
        }
Beispiel #5
0
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            string          ip  = null;
            BluetoothDevice dev = null;

            switch (requestCode)
            {
            case AddReaderBt:
                if (resultCode == Result.Ok)
                {
                    dev = (BluetoothDevice)((Intent)data).GetParcelableExtra("BT_DEVICE");

                    _tcpBtWaitProgressDialog = ProgressDialog.Show(this,
                                                                   "Connection ", "Connecting to " + dev.Name, true,
                                                                   true);

                    await Task.Run(() =>
                    {
                        BluetoothSocket sock;
                        CAENRFIDReader reader   = null;
                        CAENRFIDReaderInfo info = null;
                        string fwrel            = null;

                        bool no_connection = true;

                        try
                        {
                            sock = dev.CreateRfcommSocketToServiceRecord(_myUuid);

                            reader = new CAENRFIDReader();


                            reader.Connect(sock);
                            var state = dev.BondState;

                            while (state != Bond.Bonded)
                            {
                                state = dev.BondState;
                            }


                            info  = reader.ReaderInfo;
                            fwrel = reader.FirmwareRelease;

                            DemoReader dr = new DemoReader(reader, info.Model,
                                                           info.SerialNumber, fwrel, CAENRFIDPort.CaenrfidBt);
                            Readers.Add(dr);
                        }
                        catch (CAENRFIDException e)
                        {
                            Log.Error(TAG, "Exception " + e.Message);

                            Toast.MakeText(ApplicationContext, "Failed", ToastLength.Long);
                        }
                    });


                    UpdateReadersList();
                    _tcpBtWaitProgressDialog.Dismiss();
                }
                break;
            }
        }