Example #1
0
        //sensor input change event handler...Set the textbox content based on the input index that is communicating with the
        //interface kit
        //also, display the sensor information in the attached TextLCD
        void ifk_SensorChange(object sender, SensorChangeEventArgs e)
        {
            sensorInArray[e.Index].Text = e.Value.ToString();

            lcd.rows[0].DisplayString = "Sensor: " + e.Index;
            lcd.rows[1].DisplayString = "Value: " + e.Value;
        }
Example #2
0
 //Sensor input change event handler
 public void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     if (e.Value < 10)
     {
         GoodTouch = true;
     }
     else if ((e.Value < 400) && (e.Value > 100) && GoodTouch)
     {
         if (prgbar_social.Value + 10 >= prgbar_social.Maximum)
         {
             prgbar_social.Value = prgbar_social.Maximum;
         }
         else
         {
             prgbar_social.Value = prgbar_social.Value + 5;
         }
     }
     else if (e.Value >= 400)
     {
         GoodTouch = false;
         if (prgbar_social.Value <= 10)
         {
             prgbar_social.Value = 0;
         }
         else
         {
             prgbar_social.Value = prgbar_social.Value - 5;
         }
     }
 }
Example #3
0
 void ifk_SensorChange(object sender, SensorChangeEventArgs e)
 {
     this.Dispatcher.Invoke(new Action(delegate()
     {
         sensorInArray[e.Index].Text = e.Value.ToString();
     }));
 }
Example #4
0
        protected override void SensorChange(object sender, SensorChangeEventArgs ex)
        {
            // We only care about the index we are watching
            if (ex.Index != Index)
            {
                return;
            }

            currentValue = ex.Value;

            bool shouldTrigger = false;

            // Take the xor of whether we should trigger and whether to invert the result
            if (OnTurnOn ^ invert && currentValue >= TopThreshold && lastValue < TopThreshold)
            {
                shouldTrigger = true;
            }
            else if (!OnTurnOn ^ invert && currentValue <= BottomThreshold && lastValue > BottomThreshold)
            {
                shouldTrigger = true;
            }

            if (shouldTrigger)
            {
                Trigger();
            }

            lastValue = currentValue;
        }
Example #5
0
 private void InterfaceKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     if (e.Index == KnobIndex)
     {
         Debug.WriteLine("Knob change: " + e.Value);
         updateFromKnobValue(e.Value);
     }
 }
Example #6
0
        //Sensor input change event handler
        //Set the textbox content based on the input index that is communicating
        //with the interface kit
        void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            sensorInArray[e.Index].Text = e.Value.ToString();

            if (advSensorForm != null)
            {
                advSensorForm.SetValue(e.Index, e.Value);
            }
        }
 //Sensor Change event handler...Display the sensor index and it's new value to
 //the console
 void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     if (e.Index == 0)
     {
         this.label1.Text = e.Value.ToString();
         sensor1_value = e.Value;
         bool on = sensor1_value > 500;
         ifKit.outputs[0] = on;
         label6.Text = on.ToString();
     }
 }
Example #8
0
 protected void SensorChange(object sender, SensorChangeEventArgs e)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
     {
         // We only care about the index we are looking at.
         if (e.Index == Index && Convertor != null)
         {
             SetString(Convertor(e.Value));
         }
     }));
 }
 static void InterfaceKitSensorChange(object sender, SensorChangeEventArgs e)
 {
     switch(e.Index){
     case 0:
         PlayerJetpack.sensorValue = e.Value;
         break;
     case 1:
         PlayerPunch.firstValue = e.Value;
         break;
     case 2:
         PlayerPunch.secondValue = e.Value;
         break;
     }
 }
Example #10
0
        private void kit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            if (e.Index == 0)
            {
                lblSensorValue.Text = e.Value.ToString();

                if (e.Value < 400 || e.Value > 600)
                {
                    isParty           = true;
                    tmrMotion.Enabled = true;
                }
            }

            lblPartyMode.Text = (isParty) ? "ON" : "OFF";
        }
Example #11
0
        //Sensor input change event handler
        public void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            if (e.Index == 0)
            {
                circleArray[e.Index].changeColor(Color.FromArgb(e.Value * 1 / 4, e.Value * 1 / 4, e.Value * 1 / 4));
                circleArray[e.Index].changeSize(new Point((e.Value) + 1, (e.Value) + 1));
            }



            g.Clear(Color.Black);

            for (int i = 0; i < 8; i++)
            {
                // Draw (with gradients)
                circleArray[i].Draw("");
            }
        }
Example #12
0
        protected override void SensorChange(object sender, SensorChangeEventArgs ex)
        {
            // We only care about the index we are watching
            if (ex.Index != Index)
            {
                return;
            }

            if (IsValidInput(ex.Value))
            {
                currentValue = Convert(ex.Value);

                if (IsInRange(currentValue) && !IsInRange(lastValue))
                {
                    Trigger();
                }

                lastValue = currentValue;
            }
        }
Example #13
0
    // Analog Inputs Event Handler
    static void ifKit1_SensorChange(object sender, SensorChangeEventArgs e)
    {
        if (e.Value > minTouchVal)
        {
            ResetTouchSensors();

            if (e.Index == 0)
            {
                Instance.ifKit1Inputs[0] = true;
            }
            else if (e.Index == 1)
            {
                Instance.ifKit1Inputs[1] = true;
            }
            else if (e.Index == 2)
            {
                Instance.ifKit1Inputs[2] = true;
            }
        }
        else
        {
            ResetTouchSensors();
        }

        //rotary potentiometer
        if (e.Index == 3)
        {
            float originEncoderVal = e.Value;

            //if the gap between values is bigger than 'debounceValue', then ignore value.
            if (Mathf.Abs(originEncoderVal - ifKit1LastEncoderVal) < Instance.debounceValue)
            {
                Instance.ifKit1EncoderVal = Map(0.0f, 360.0f, 0.0f, 999.9f, originEncoderVal);
                //Debug.Log (originEncoderVal +" | " + Mathf.Abs(originEncoderVal-lastEncoderVal)+ " < " + Instance.debounceValue);
            }
            ifKit1LastEncoderVal = originEncoderVal;
        }
    }
Example #14
0
        //Sensor input change event handler
        public void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            //Differentiates between "good touches" and "bad touches" based on
            //amount of force exerted onto the force sensor.
            Pandy.PandyVisDesg_TouchSensorOff();
            if (e.Value < 10)
            {
                GoodTouch = true;
            }
            else if ((e.Value < 450) && (e.Value > 100) && GoodTouch)
            {
                if (prgbar_social.Value + 10 >= prgbar_social.Maximum)
                {
                    Pandy.PandyVisDesg_TouchSensorOn();
                    prgbar_social.Value = prgbar_social.Maximum;
                }
                else
                {
                    Pandy.PandyVisDesg_TouchSensorOn();
                    prgbar_social.Value = prgbar_social.Value + 5;
                }
            }
            else if (e.Value >= 450)
            {
                GoodTouch = false;
                if (prgbar_social.Value <= 10)
                {
                    Pandy.PandyVisDesg_TouchSensorOn();
                    prgbar_social.Value = 0;
                }

                else
                {
                    Pandy.PandyVisDesg_TouchSensorOn();
                    prgbar_social.Value = prgbar_social.Value - 2;
                }
            }
        }
Example #15
0
        private void InterfaceKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            if (e.Index == KnobIndex)
            {
                Console.WriteLine("Knob change: " + e.Value);
                if (servoMotor != null)
                {
                    // normalize knob rotation
                    double normalRot = e.Value / 1000f;
                    servoMotor.Position = CosineInterpolate(servoMotor.PositionMin, servoMotor.PositionMax, normalRot);
                    Console.WriteLine("new servo position: " + servoMotor.Position);

                    // Create a message and populate it
                    Message message = new Message("SERVO_POSITION");
                    message.AddField <double>("position", servoMotor.Position);
                    message.AddField <double>("positionMin", servoMotor.PositionMin);
                    message.AddField <double>("positionMax", servoMotor.PositionMax);

                    // Send the message
                    client.SendMessage(message);
                }
            }
        }
Example #16
0
        protected override void SensorChange(object sender, SensorChangeEventArgs ex)
        {
            // We only care about the index we are watching
            if (ex.Index != Index)
            {
                return;
            }

            if (IsValidRange(ex.Value))
            {
                CurrentValue = Convert(ex.Value);

                if (Increasing && CurrentValue > TopValue && LastValue < TopValue)
                {
                    Trigger();
                }
                else if (!Increasing && CurrentValue < TopValue && LastValue > TopValue)
                {
                    Trigger();
                }

                LastValue = CurrentValue;
            }
        }
Example #17
0
 //sensor input change event handler...Set the textbox content based on the input index that is
 //communicating with the interface kit
 void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     sensorInArray[e.Index].Text = e.Value.ToString();
 }
Example #18
0
 private void InterfaceKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     if (e.Index == KnobIndex)
     {
         Debug.WriteLine("Knob change: " + e.Value);
         updateFromKnobValue(e.Value);
     }
 }
        //    void ifKit_OutputChange(object sender, OutputChangeEventArgs e)
        //{
        //    // try
        //    // {   _888IfKitRep obj = new _888IfKitRep();
        //    //     obj.SetOutputs(e.Index, ifKit.outputs[e.Index], Serialnumber);
        //    // }
        //    //catch (Exception ex)
        //    //{

        //    //    Errors err = new Errors();
        //    //    err.Card = Serialnumber;
        //    //    err.Date = DateTime.Now.ToString();
        //    //    err.From = System.Environment.MachineName;
        //    //    err.Message = ex.Message;
        //    //    err.Method = "ifKit_OutputChange";

        //    //objErr.AddErrors(err);
        //    //}
        //}



        void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
        {


            SensorerFac sf = new SensorerFac();
            sf.SetSensor(e.Index, ifKit.sensors[e.Index].Value, Serialnumber);

           
            try
            {

            }
            catch (Exception ex)
            {

                //Errors err = new Errors();
                //err.Card = Serialnumber;
                //err.Date = DateTime.Now.ToString();
                //err.From = System.Environment.MachineName;
                //err.Message = ex.Message;
                //err.Method = "ifKit_SensorChange";

                //objErr.AddErrors(err);
            }
        }
            //Sensor Change event handler...Display the sensor index and it's new value to 
            //the console
            public void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
            {
                Console.WriteLine("Sensor index {0} value {1}", e.Index, e.Value);

                try
                {
                    PhidgetStarterKitModule phidgetData = (PhidgetStarterKitModule)_phidgetData;
                    phidgetData.AnalogInput[e.Index] = e.Value;

                    // Call SendToPhidgetClients(PSx, data).
                    Console.WriteLine(string.Format("SendToPhidgetClients: {0} / {1}", _phidgetServerDetails.MachineName, _phidgetData.ToString()));
                    _phidgetServer.PhidgetServerHubProxy.Invoke("SendToPhidgetClients", _phidgetServerDetails, phidgetData).ContinueWith(task =>
                    {
                        if (task.IsFaulted)
                        {
                            Console.WriteLine("!!! There was an error on SendToPhidgetClients call: {0}  \n", task.Exception.GetBaseException().Message);
                        }
                    }).Wait();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Example #21
0
        //Sensor input change event handler
        //Set the textbox content based on the input index that is communicating
        //with the interface kit
        void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            sensorInArray[e.Index].Text = e.Value.ToString();

            if (advSensorForm != null)
                advSensorForm.SetValue(e.Index, e.Value);
        }
Example #22
0
        private void InterfaceKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            if (e.Index == KnobIndex)
            {
                Console.WriteLine("Knob change: " + e.Value);
                if (servoMotor != null)
                {
                    // normalize knob rotation
                    double normalRot = e.Value / 1000f;
                    servoMotor.Position = CosineInterpolate(servoMotor.PositionMin, servoMotor.PositionMax, normalRot);
                    Console.WriteLine("new servo position: " + servoMotor.Position);

                    // Create a message and populate it
                    Message message = new Message("SERVO_POSITION");
                    message.AddField<double>("position", servoMotor.Position);
                    message.AddField<double>("positionMin", servoMotor.PositionMin);
                    message.AddField<double>("positionMax", servoMotor.PositionMax);

                    // Send the message
                    client.SendMessage(message);
                }
            }
        }
Example #23
0
 // Visualise pressure sensors input
 private void currentInterfaceKitBoard_SensorChange(object sender, SensorChangeEventArgs e)
 {
     switch (e.Index)
     {
         case 0:
             progressBar1.Value = e.Value;
             break;
         case 1:
             progressBar2.Value = e.Value;
             break;
         case 2:
             progressBar3.Value = e.Value;
             break;
         case 3:
             progressBar4.Value = e.Value;
             break;
         case 4:
             progressBar5.Value = e.Value;
             break;
         case 5:
             progressBar6.Value = e.Value;
             break;
         case 6:
             progressBar7.Value = e.Value;
             break;
         case 7:
             progressBar8.Value = e.Value;
             break;
         default:
             Console.WriteLine("Sensor at index " + e.Index + " not supported");
             break;
     }
 }
 //Checks for sensor change and returns the value to the IF kit
 private static void onSensorChange(object sender, SensorChangeEventArgs e)
 {
     sensorValues[e.Index] = e.Value;
 }
Example #25
0
 //sensor input change event handler...Set the textbox content based on the input index that is
 //communicating with the interface kit
 void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     sensorInArray[e.Index].Text = e.Value.ToString();
 }
Example #26
0
        private void intfKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            _currentPressureData[e.Index] = e.Value;

            // Check current state of this actuator pressure state.
            // If press gesture is recognised, fire appropriate event
            if (actuatorExist(e.Index)) 
            {
                getActuator(e.Index).setPressure(e.Value);
                if (e.Value > INPUT_PRESSURE_THRESHOLD && 
                    (!_inputData.ContainsKey(e.Index) ||
                        _inputData[e.Index].Item2 == PRESSURE_STATE.BELOW_THRESHOLD))
                {
                   _inputData[e.Index] = new Tuple<DateTime, PRESSURE_STATE>(DateTime.Now, PRESSURE_STATE.ABOVE_THRESHOLD);
                }
                else if (e.Value < INPUT_PRESSURE_THRESHOLD && _inputData.ContainsKey(e.Index))
                {
                    TimeSpan span = DateTime.Now - _inputData[e.Index].Item1;
                    if (_inputData.ContainsKey(e.Index) && 
                        _inputData[e.Index].Item2 == PRESSURE_STATE.ABOVE_THRESHOLD && 
                            span.TotalMilliseconds < PRESS_GESTURE_TIME_CONSTRAINT)
                    {
                        OnPressureGesture(PRESSURE_GESTURE_TYPE.PRESS);
                    }
                    _inputData[e.Index] = new Tuple<DateTime, PRESSURE_STATE>(DateTime.Now, PRESSURE_STATE.BELOW_THRESHOLD);
                }
                Helper.Logger("HaptiQ_API.HaptiQ.intfKit_SensorChange::InterfaceKit Sensors Changed (" + e.Index + "): " + e.Value);
            }

            // Fire an event for this pressure sensor
            OnPressureInput(e.Index, e.Value);
        }
Example #27
0
        //Sensor input change event handler
        //Set the textbox content based on the input index that is communicating
        //with the interface kit
        void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            //sensorInArray[e.Index].Text = e.Value.ToString();
            string str;

            switch (e.Index)
            {
            case 0:
            case 1:
            {
                double value = n_specialSensors[e.Index].changeDisplay(e.Value, out str);

                if (m_useDebugValue == true)
                {
                    m_specialSensors[0] = m_config[4].value;
                    m_specialSensors[1] = m_config[5].value;
                }
                else
                {
                    m_specialSensors[e.Index] = value;
                }

                if (m_sensorEvent != null)
                {
                    m_eventCode[PhidgetCallbackCode.SENSORCHANGE]++;
                    m_sensorEvent.Set();
                }
            }
            break;

            case 2:
            {
                double value = n_specialSensors[e.Index].changeDisplay(e.Value, out str);

                if (m_useDebugValue == true)
                {
                    m_specialSensors[2] = m_config[6].value;
                }
                else
                {
                    m_specialSensors[e.Index] = value;
                }

                if (m_sensorEvent != null)
                {
                    m_eventCode[PhidgetCallbackCode.SENSORCHANGE]++;
                    m_sensorEvent.Set();
                }
            }
            break;

            default:
            {
                Console.WriteLine("Unknown: " + e.Index);
            }
            break;
            }

            // if (advSensorForm != null)
            // advSensorForm.SetValue(e.Index, e.Value);
        }
 void ifk_SensorChange(object sender, SensorChangeEventArgs e)
 {
     this.Dispatcher.Invoke(new Action(delegate()
         {
             sensorInArray[e.Index].Text = e.Value.ToString();
         }));
 }
Example #29
0
 protected abstract void SensorChange(object sender, SensorChangeEventArgs ex);
Example #30
0
 //Sensor Change event handler...Display the sensor index and it's new value to
 //the console
 static void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     //if (e.Index == 0)
     //    Console.WriteLine("Sensor index {0} value {1}", e.Index, e.Value);
     //Console.Out.Flush();
 }
Example #31
0
 void SensorChange(object sender, SensorChangeEventArgs e)
 {
     FChanged = true;
 }
Example #32
0
        /// <summary>
        /// Event handler for change in sensor reading from interface kit
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event arguments</param>
        private void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
        {
            if (e.Index == SENSOR_WEIGHT_ID)
            {
                this.currWeight = e.Value;
            }
            else if (e.Index == SENSOR_IR_ID && e.Value > DISTANCE_THRESHOLD)
            {
                if (!open)
                {
                    open = true;
                    Thread lidThread = new Thread(new ThreadStart(this.openCan));
                    lidThread.Start();
                }
            }
            else if (e.Index == SENSOR_LEVEL_ID && e.Value > LEVEL_THRESHOLD && !open && currWeight > 150)
            {
                fullCan();
            }
            else if (e.Index == SENSOR_ROTATION_ID)
            {
                changeTrashType(e);
            }

            else if (currWeight < 150 && !open && !fullLock)
            {
                notFullCan();
            }
        }
Example #33
0
 /// <summary>
 /// Light up the correct LED indicating trash type based on rotation value
 /// </summary>
 /// <param name="e">Event arguments</param>
 private void changeTrashType(SensorChangeEventArgs e)
 {
     updateTrashLEDs(e.Value);
 }
 static void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     Console.WriteLine("Sensor index {0} value {1}" + " " + e.Index + " " + e.Value);
 }
Example #35
0
 void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     //Debug.Log ("value of sensor right now is " + e.Value);
     forces.Enqueue ((float)e.Value/(25.71*2));
 }
Example #36
0
        //sensor input change event handler...Set the textbox content based on the input index that is communicating with the
        //interface kit
        //also, display the sensor information in the attached TextLCD
        void ifk_SensorChange(object sender, SensorChangeEventArgs e)
        {
            sensorInArray[e.Index].Text = e.Value.ToString();

            lcd.rows[0].DisplayString = "Sensor: " + e.Index;
            lcd.rows[1].DisplayString = "Value: " + e.Value;
        }
Example #37
0
 //Sensor Change event handler...Display the sensor index and it's new value to 
 //the console
 static void ifKit_SensorChange(object sender, SensorChangeEventArgs e)
 {
     Console.WriteLine("Sensor index {0} value {1}", e.Index, e.Value);
 }