예제 #1
0
        public mainFrm()
        {
            InitializeComponent();
#if ASYNCHRONOUS
            try
            {
                mySensor = new Sensor(this, Sensor.SensorsEnabled.AccelerometerEnabled, true);
            }
            catch (Exception)
            {
                MessageBox.Show("No sensor available. Did you install SensorCab runtime? Exit");
                Application.Exit();
            }
            //call mySensor_AccelerationEvent for Acceleration events from sensor
            mySensor.AccelerationMinimumNotifyDelta = 0;
            mySensor.SensorDataUpdateInterval = 10;
            mySensor.AccelerationEvent += new AccelerationEventHandler(mySensor_AccelerationEvent);
#else
            //mySensor = new Sensor(this, Sensor.SensorsEnabled.AccelerometerEnabled, false);
#endif
            cbSensity.SelectedIndex = 3; //default is 0.01, 0 means all events
            trackBar1.Value = 100;

            //mySensor.SensorDataUpdateInterval = 50;

            //
            shaker1 = new ShakeDetection.ShakeClass1("shake1");
            shaker1.shakeTreshold = 8.0;
            //shaker1.logEnabled = true;
            //better implementation
            shaker1.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker1_ShakeDetected);
            //
            shaker2 = new ShakeDetection.ShakeClass2("shake2");
            //shaker2.logEnabled = true;
            shaker2.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker2_ShakeDetected);

            //
            shaker3 = new ShakeDetection.ShakeClass3("shake3");
            //shaker3.logEnabled = true;
            shaker3.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker3_ShakeDetected);

            //
            shaker4 = new ShakeDetection.ShakeClass4("shake4");
            //shaker4.logEnabled = true;
            shaker4.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker4_ShakeDetected);

            //
            shaker5 = new ShakeDetection.ShakeClass5("shake5");
            trackBar5.Value = 8; trackBar1_ValueChanged(this, null);
            //shaker5.logEnabled = true;
            shaker5.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker5_ShakeDetected);

            //
            shaker6 = new ShakeDetection.ShakeClass6("shake6");
            //shaker6.logEnabled = true;
            shaker6.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker6_ShakeDetected);
            trackBar6.Value = 120;

            //
            shaker7 = new ShakeDetection.ShakeClass7("shake7");
            //shaker7.logEnabled = true;
            shaker7.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker7_ShakeDetected);

            //
            shaker8 = new ShakeDetection.ShakeClass8("shake8");
            //shaker8.logEnabled = true;
            shaker8.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker8_ShakeDetected);

            //
            shaker9 = new ShakeDetection.ShakeClass9("shake9");
            //shaker8.logEnabled = true;
            shaker9.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker9_ShakeDetected);

            //
            move1 = new Movedetection.MovementClass1("move1");
            move1.logEnabled = true;
            move1.MoveDetected += new Movedetection.MovementClass.MoveDetectedEventHandler(move1_MoveDetected);
            move1.IdleDetected += new Movedetection.MovementClass.IdleDetectedEventHandler(move1_IdleDetected);

#if !ASYNCHRONOUS
            //myTimer.Interval = 50; //approx 20 events per second
            //myTimer.Tick += new EventHandler(myTimer_Tick);
            //myTimer.Enabled = true; //do not enable timer before assigning the shaker/move classes
            //myTimer.Enabled = true;
            myThread = new bgThread();
            myThread.bgThreadEvent += new bgThread.bgThreadEventHandler(myThread_bgThreadEvent);
#endif
            //perfChart1.maxDecimal = 1500;
            perfChart1._SymmetricDisplay= true;
            perfChart1._ScaleMode = SpPerfChart.ScaleMode.Relative;
            //perfChart2.maxDecimal = 1500;
            perfChart2._SymmetricDisplay = true;
            perfChart2._ScaleMode = SpPerfChart.ScaleMode.Relative;
            //perfChart3.maxDecimal = 1500;
            perfChart3._SymmetricDisplay = true;
            perfChart3._ScaleMode = SpPerfChart.ScaleMode.Relative;

            perfChart4._SymmetricDisplay = true;
            perfChart4._ScaleMode = SpPerfChart.ScaleMode.Relative;

            starting = false;

#if USE_SCANNER
            scanEvents = new ScanEvents();
            try
            {
                bcr = new BarcodeReader();
                bcr.ContinuesScan = true;
                scanTimer = new Timer();
                scanTimer.Interval = 1000; //fire every second
                scanTimer.Tick += new EventHandler(scanTimer_Tick);
                scanTimer.Enabled = true;
            }
            catch (Exception)
            {
                //scanner not available                
            }
#endif
        }
예제 #2
0
        public mainFrm()
        {
            InitializeComponent();
#if ASYNCHRONOUS
            try
            {
                mySensor = new Sensor(this, Sensor.SensorsEnabled.AccelerometerEnabled, true);
            }
            catch (Exception)
            {
                MessageBox.Show("No sensor available. Did you install SensorCab runtime? Exit");
                Application.Exit();
            }
            //call mySensor_AccelerationEvent for Acceleration events from sensor
            mySensor.AccelerationMinimumNotifyDelta = 0;
            mySensor.SensorDataUpdateInterval       = 10;
            mySensor.AccelerationEvent += new AccelerationEventHandler(mySensor_AccelerationEvent);
#else
            //mySensor = new Sensor(this, Sensor.SensorsEnabled.AccelerometerEnabled, false);
#endif
            cbSensity.SelectedIndex = 3; //default is 0.01, 0 means all events
            trackBar1.Value         = 100;

            //mySensor.SensorDataUpdateInterval = 50;

            //
            shaker1 = new ShakeDetection.ShakeClass1("shake1");
            shaker1.shakeTreshold = 8.0;
            //shaker1.logEnabled = true;
            //better implementation
            shaker1.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker1_ShakeDetected);
            //
            shaker2 = new ShakeDetection.ShakeClass2("shake2");
            //shaker2.logEnabled = true;
            shaker2.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker2_ShakeDetected);

            //
            shaker3 = new ShakeDetection.ShakeClass3("shake3");
            //shaker3.logEnabled = true;
            shaker3.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker3_ShakeDetected);

            //
            shaker4 = new ShakeDetection.ShakeClass4("shake4");
            //shaker4.logEnabled = true;
            shaker4.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker4_ShakeDetected);

            //
            shaker5         = new ShakeDetection.ShakeClass5("shake5");
            trackBar5.Value = 8; trackBar1_ValueChanged(this, null);
            //shaker5.logEnabled = true;
            shaker5.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker5_ShakeDetected);

            //
            shaker6 = new ShakeDetection.ShakeClass6("shake6");
            //shaker6.logEnabled = true;
            shaker6.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker6_ShakeDetected);
            trackBar6.Value        = 120;

            //
            shaker7 = new ShakeDetection.ShakeClass7("shake7");
            //shaker7.logEnabled = true;
            shaker7.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker7_ShakeDetected);

            //
            shaker8 = new ShakeDetection.ShakeClass8("shake8");
            //shaker8.logEnabled = true;
            shaker8.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker8_ShakeDetected);

            //
            shaker9 = new ShakeDetection.ShakeClass9("shake9");
            //shaker8.logEnabled = true;
            shaker9.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker9_ShakeDetected);

            //
            move1               = new Movedetection.MovementClass1("move1");
            move1.logEnabled    = true;
            move1.MoveDetected += new Movedetection.MovementClass.MoveDetectedEventHandler(move1_MoveDetected);
            move1.IdleDetected += new Movedetection.MovementClass.IdleDetectedEventHandler(move1_IdleDetected);

#if !ASYNCHRONOUS
            //myTimer.Interval = 50; //approx 20 events per second
            //myTimer.Tick += new EventHandler(myTimer_Tick);
            //myTimer.Enabled = true; //do not enable timer before assigning the shaker/move classes
            //myTimer.Enabled = true;
            myThread = new bgThread();
            myThread.bgThreadEvent += new bgThread.bgThreadEventHandler(myThread_bgThreadEvent);
#endif
            //perfChart1.maxDecimal = 1500;
            perfChart1._SymmetricDisplay = true;
            perfChart1._ScaleMode        = SpPerfChart.ScaleMode.Relative;
            //perfChart2.maxDecimal = 1500;
            perfChart2._SymmetricDisplay = true;
            perfChart2._ScaleMode        = SpPerfChart.ScaleMode.Relative;
            //perfChart3.maxDecimal = 1500;
            perfChart3._SymmetricDisplay = true;
            perfChart3._ScaleMode        = SpPerfChart.ScaleMode.Relative;

            perfChart4._SymmetricDisplay = true;
            perfChart4._ScaleMode        = SpPerfChart.ScaleMode.Relative;

            starting = false;

#if USE_SCANNER
            scanEvents = new ScanEvents();
            try
            {
                bcr = new BarcodeReader();
                bcr.ContinuesScan  = true;
                scanTimer          = new Timer();
                scanTimer.Interval = 1000; //fire every second
                scanTimer.Tick    += new EventHandler(scanTimer_Tick);
                scanTimer.Enabled  = true;
            }
            catch (Exception)
            {
                //scanner not available
            }
#endif
        }