Esempio n. 1
0
        private void InitializeWocketParameters()
        {
            //Load Wocket Parameters
            WocketsConfiguration configuration = new WocketsConfiguration();
            CurrentWockets._Configuration = configuration;


            wc = new WocketsController("", "", "");
            CurrentWockets._Controller = wc;
            wc._Receivers = new ReceiverList();
            wc._Decoders = new DecoderList();
            wc._Sensors = new SensorList();
            wc._Receivers.Add(new RFCOMMReceiver());
            wc._Decoders.Add(new WocketsDecoder());
            wc._Sensors.Add(new Wocket());

            ((RFCOMMReceiver)wc._Receivers[0])._Address = this.wocket.DeviceAddress.ToString();
            wc._Receivers[0]._ID = 0;
            wc._Decoders[0]._ID = 0;
            wc._Sensors[0]._Receiver = wc._Receivers[0];
            wc._Sensors[0]._Decoder = wc._Decoders[0];
            ((Accelerometer)wc._Sensors[0])._Max = 1024;
            ((Accelerometer)wc._Sensors[0])._Min = 0;
            wc._Sensors[0]._Loaded = true;
            //wc._Decoders[0].Subscribe(Wockets.Data.SensorDataType.COMMAND_MODE_ENTERED, new Response.ResponseHandler(this.CommandCallback));
            //wc._Decoders[0].Subscribe(Wockets.Data.SensorDataType.BAUD_RATE, new Response.ResponseHandler(this.CommandCallback));
            wc.Initialize();

        }
Esempio n. 2
0
        private void button_Ini_Click(object sender, EventArgs e)
        {
            if (button_Ini.Text.CompareTo("Start") == 0)
            {
                button_Ini.Enabled = false;
                Application.DoEvents();
                //--------------------

                IniWocket();

                wc._Receivers.Add(new RFCOMMReceiver());
                ((RFCOMMReceiver)wc._Receivers[0])._Address = this.wocket.DeviceAddress.ToString();
                wc._Receivers[0]._ID     = 0;
                wc._Sensors[0]._Receiver = wc._Receivers[0];

                wc.Initialize();


                //--------------------
                button_Ini.Text    = "Stop";
                button_Ini.Enabled = true;
            }
            else
            {
                button_Ini.Enabled = false;
                Application.DoEvents();
                //-----------------------
                wc._Receivers[0].Dispose();


                //------------------------
                button_Ini.Text    = "Start";
                button_Ini.Enabled = true;
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.listBox1.SelectedIndex >= 0)
            {
                this.label2.Text = "Testing... please wait";
                this.label2.Update();
                WocketsConfiguration configuration = new WocketsConfiguration();
                CurrentWockets._Configuration = configuration;
                WocketsController wc = new WocketsController("", "", "");
                CurrentWockets._Controller = wc;
                wc._Receivers = new ReceiverList();
                wc._Decoders  = new DecoderList();
                wc._Sensors   = new SensorList();
                wc._Receivers.Add(new RFCOMMReceiver());
                wc._Decoders.Add(new WocketsDecoder());
                wc._Sensors.Add(new Wocket());

                ((RFCOMMReceiver)wc._Receivers[0])._Address = ((BluetoothDeviceInfo)bluetoothlist[(string)this.listBox1.Items[this.listBox1.SelectedIndex]]).DeviceAddress.ToString();
                wc._Receivers[0]._ID                 = 0;
                wc._Decoders[0]._ID                  = 0;
                wc._Sensors[0]._Receiver             = wc._Receivers[0];
                wc._Sensors[0]._Decoder              = wc._Decoders[0];
                ((Accelerometer)wc._Sensors[0])._Max = 1024;
                ((Accelerometer)wc._Sensors[0])._Min = 0;
                wc._Sensors[0]._Loaded               = true;



                //---- initialize wocket controller -------
                wc.Initialize();
                wocketCount = 0;
                while (true)
                {
                    if (wc._Receivers[0]._Status == ReceiverStatus.Connected)
                    {
                        MessageBox.Show("Success: connected to wocket.");
                        Environment.Exit(0);
                    }

                    Thread.Sleep(1000);
                    wocketCount++;
                    if (wocketCount > 20)
                    {
                        MessageBox.Show("Failed: cannot connect to wocket!");
                        Environment.Exit(0);
                    }
                }
            }
        }