public float getIR(int position) { ArrayList list = new ArrayList(); if (!SensorsDictionary.TryGetValue(SensorTypes.IRSensor, out list)) { throw new NoInstanceException(); } if (list.Count <= position) { throw new IndexOutOfRangeException(); } ListEntry le = (ListEntry)list[position]; float value = Defines.INVALID_FLOAT; if (le.Adapter.AdapterType == AdapterTypes.AnalogSensorAdapter) { AnalogSensorAdapter adapter = (AnalogSensorAdapter)le.Adapter; value = adapter.get(); } else if (le.Adapter.AdapterType == AdapterTypes.AnalogSensorArrayAdapter) { AnalogSensorArrayAdapter adapter = (AnalogSensorArrayAdapter)le.Adapter; value = adapter.get(le.BeginOffset); } if (value == Defines.INVALID_FLOAT) { throw new InvalidValueException("Cannot get true value."); } return(value); }
public float getSonar(int position) { ArrayList list = new ArrayList(); if (!SensorsDictionary.TryGetValue(SensorTypes.UltraSonicSonar, out list)) { throw new NoInstanceException(); } if (list.Count <= position) { throw new IndexOutOfRangeException(); } ListEntry le = (ListEntry)list[position]; float value = Defines.INVALID_FLOAT; SonarAdapter adapter = (SonarAdapter)le.Adapter; value = adapter.get(); if (value == Defines.INVALID_FLOAT) { throw new InvalidValueException("Cannot get true value."); } return(value); }
public float getContact(int index) { ArrayList list = new ArrayList(); if (!SensorsDictionary.TryGetValue(SensorTypes.ContactSensorArray, out list)) { throw new NoInstanceException(); } if (list.Count == 0 || list.Count < index + 1) { throw new IndexOutOfRangeException(); } ListEntry le = (ListEntry)list[index]; float value = Defines.INVALID_FLOAT; if (le.Adapter.AdapterType == AdapterTypes.ContactSensorArrayAdapter) { ContactSensorArrayAdapter adapter = (ContactSensorArrayAdapter)le.Adapter; if (adapter.get(le.BeginOffset)) { value = 1; } else { value = 0; } } if (value == Defines.INVALID_FLOAT) { throw new InvalidValueException("Cannot get true value."); } return(value); }
public float[] getContact() { ArrayList list = new ArrayList(); if (!SensorsDictionary.TryGetValue(SensorTypes.ContactSensorArray, out list)) { throw new NoInstanceException(); } float[] ret = new float[list.Count]; for (int index = 0; index < list.Count; index++) { ListEntry le = (ListEntry)list[index]; ret[index] = Defines.INVALID_FLOAT; if (le.Adapter.AdapterType == AdapterTypes.ContactSensorArrayAdapter) { ContactSensorArrayAdapter adapter = (ContactSensorArrayAdapter)le.Adapter; if (adapter.get(le.BeginOffset)) { ret[index] = 1; } else { ret[index] = 0; } } if (ret[index] == Defines.INVALID_FLOAT) { throw new InvalidValueException("Cannot get true value."); } } return(ret); }