public bool GetSensorValue(NxtBrick.Sensor sensor, out NxtBrick.SensorValues values)
        {
            SensorValues sv;
            bool ret = base.GetSensorValue((Sensor)sensor, out sv);

            values = sv;
            return ret;
        }
 public override bool ClearSensor(NxtBrick.Sensor sensor)
 {
     if (SensorDic.ContainsKey(sensor))
     {
         SensorDic[sensor] = NxtBrick.SensorType.NoSensor;
         return true;
     }
     print("no sensor {0} to clear", sensor);
     return false;
 }
        public override bool GetSensorValue(NxtBrick.Sensor sensor, out NxtBrick.SensorValues sensorValues)
        {            
            sensorValues = new NxtBrick.SensorValues();
            sensorValues.Raw = ushort.MinValue;

            if (IsConnected)
            {
                switch (SensorDic[sensor])
                {
                    case NxtBrick.SensorType.NoSensor:
                        break;
                    case NxtBrick.SensorType.Switch:
                        break;
                    case NxtBrick.SensorType.Temperature:
                        break;
                    case NxtBrick.SensorType.Reflection:
                        break;
                    case NxtBrick.SensorType.Angle:
                        break;
                    case NxtBrick.SensorType.LightActive:
                        break;
                    case NxtBrick.SensorType.LightInactive:
                        break;
                    case NxtBrick.SensorType.SoundDB:
                        break;
                    case NxtBrick.SensorType.SoundDBA:
                        break;
                    case NxtBrick.SensorType.Custom:
                        break;
                    case NxtBrick.SensorType.Lowspeed:
                        break;
                    case NxtBrick.SensorType.Lowspeed9V:
                        break;
                    default:
                        print("Problem: could not retrieve data because of unknown sensor type {0} set for sensor {1}",
                            SensorDic[sensor], sensor);
                        return false;
                }
                return true;
            }
            print("Problem: could not retrieve data because of broken connection");
            return false;
        }
 public bool SetMotorState(NxtBrick.Motor motor, NxtBrick.MotorState state)
 {
     
     return base.SetMotorState((Motor)motor, state);
 }
 public bool GetUltrasonicSensorsValue(NxtBrick.Sensor sensor, out int value)
 {
     return base.GetUltrasonicSensorsValue((Sensor)sensor, out value);
 }
 public bool SetSensorMode(NxtBrick.Sensor sensor, NxtBrick.SensorType type, NxtBrick.SensorMode mode)
 {
     return base.SetSensorMode((Sensor)sensor, (SensorType)type, (SensorMode)mode);
 }
 public bool ClearSensor(NxtBrick.Sensor sensor)
 {
     return base.ClearSensor((NXTBrick.Sensor)sensor);
 }
Esempio n. 8
0
 public abstract bool SetSensorMode(NxtBrick.Sensor sensor, NxtBrick.SensorType type, NxtBrick.SensorMode mode);
Esempio n. 9
0
 public abstract bool SetMotorState(NxtBrick.Motor motor, NxtBrick.MotorState state);
Esempio n. 10
0
 public abstract bool GetUltrasonicSensorsValue(NxtBrick.Sensor sensor, out int value);
Esempio n. 11
0
 public abstract bool GetSensorValue(NxtBrick.Sensor sensor, out NxtBrick.SensorValues sensorValues);
Esempio n. 12
0
 public abstract bool ClearSensor(NxtBrick.Sensor sensor);
 public override bool SetSensorMode(NxtBrick.Sensor sensor, NxtBrick.SensorType type, NxtBrick.SensorMode mode)
 {
     if (IsConnected)
     {
         print("sensor port {0} set to {1} type in {2} mode", sensor, type, mode);
         if (SensorDic[sensor] != NxtBrick.SensorType.NoSensor)
         {
             print("Problem: sensor {0} already set", sensor);
             return false;
         }
         if (!SensorDic.ContainsKey(sensor))
         {
             print("Problem: sensor {0} inexistent", sensor);
             return false;
         }
         SensorDic[sensor] = type;
         return true;
     }
     print("Problem: could not retrieve data because of broken connection");
     return false;
 }
 public override bool SetMotorState(NxtBrick.Motor motor, NxtBrick.MotorState state)
 {
     throw new NotImplementedException();
 }
 public override bool GetUltrasonicSensorsValue(NxtBrick.Sensor sensor, out int value)
 {           
     if (IsConnected)
     {
         Random rand = new Random();
         value = rand.Next(256);
         return true;
     }
     print("Problem: could not retrieve data because of broken connection");
     value = -1;
     return false;
 }