Пример #1
0
        public void TestMinMaxSensor()
        {
            var sensor = new MinMaxSensor();
            var parameterCount = 3;
            var typeCount = 1;

            var config = SensorTypes.GetConfig(sensor);

            Assert.AreEqual("MinMax", config.Name);
            Assert.AreEqual(typeCount, config.Types.Length);
            Assert.AreEqual("Simulator.Bridge.Data.ImageData", config.Types[0]);
            Assert.AreEqual(parameterCount, config.Parameters.Count);

            Assert.AreEqual("length", config.Parameters[0].Name);
            Assert.AreEqual(500, config.Parameters[0].DefaultValue);
            Assert.AreEqual(1f, config.Parameters[0].Min);
            Assert.AreEqual(1920f, config.Parameters[0].Max);

            Assert.AreEqual("distance", config.Parameters[1].Name);
            Assert.AreEqual(5f, config.Parameters[1].DefaultValue);
            Assert.AreEqual(0f, config.Parameters[1].Min);
            Assert.AreEqual(9f, config.Parameters[1].Max);

            Assert.AreEqual("sad", config.Parameters[2].Name);
            Assert.AreEqual(false, config.Parameters[2].DefaultValue);
            Assert.AreEqual(null, config.Parameters[2].Min);
            Assert.AreEqual(null, config.Parameters[2].Max);
        }
Пример #2
0
        /// <summary>
        /// Loads the sensor list from an xml string
        /// </summary>
        /// <param name="xml">An input string for an xml sensor list</param>
        public void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xml);
            XmlNode xNode = dom.DocumentElement;

            if ((xNode.Name == SENSORS_ELEMENT) && (xNode.HasChildNodes))
            {
                foreach (XmlNode jNode in xNode.ChildNodes)
                {
                    if (jNode.Name == Sensor.SENSOR_ELEMENT)
                    {
                        SensorClasses sensorClass = SensorClasses.Unknown;
                        SensorTypes   sensorType  = SensorTypes.UNKNOWN;
                        foreach (XmlAttribute jAttribute in jNode.Attributes)
                        {
                            if (jAttribute.Name == CLASS_ATTRIBUTE)
                            {
                                sensorClass = (SensorClasses)Enum.Parse(typeof(SensorClasses), jAttribute.Value, true);
                            }
                            else if (jAttribute.Name == TYPE_ATTRIBUTE)
                            {
                                sensorType = (SensorTypes)Enum.Parse(typeof(SensorTypes), jAttribute.Value, true);
                            }
                        }

                        if (sensorType == SensorTypes.ACCEL)
                        {
                            Sensor sensor = null;
#if (PocketPC)
                            if (sensorClass == SensorClasses.HTCDiamondTouch)
                            {
                                sensor = new HTCDiamondTouch();
                            }
                            else
#endif
                            if (sensorClass == SensorClasses.MITes)
                            {
                                sensor = new MITe();
                            }
                            else if (sensorClass == SensorClasses.Sparkfun)
                            {
                                sensor = new Sparkfun();
                            }
                            else if (sensorClass == SensorClasses.Wockets)
                            {
                                sensor = new Wocket();
                            }
                            else if (sensorClass == SensorClasses.HTCDiamondTouch)
                            {
                                sensor = new HTCDiamondTouch();
                            }
                            sensor.FromXML(jNode.OuterXml);
                            this.Insert(sensor._ID, sensor);
                        }
                    }
                }
            }
        }
Пример #3
0
        public void TestDoubleSensor()
        {
            var sensor = new DoubleSensor();

            var ex = Assert.Throws<Exception>(() => SensorTypes.GetConfig(sensor));
            Assert.True(ex.Message.Contains("Sensor Configuration Error: Simulator.Tests.Web.DoubleSensor"));
        }
Пример #4
0
 /// <summary>
 /// A constructor that initializes the sensor type and class
 /// </summary>
 /// <param name="type"></param>
 /// <param name="classname"></param>
 public Sensor(SensorTypes type, SensorClasses classname)
 {
     this._Class        = classname;
     this._Type         = type;
     this._SamplingRate = 0;
     this._Saving       = true;
 }
Пример #5
0
        public static void NewGet(
            bool isWait,
            SensorTypes sensor,
            bool isComparasion,
            char port = '0',
            ComparasionTypes comparasion = ComparasionTypes.Equal,
            Variable valueCompare        = null,
            Variable arrayCompare        = null, Variable buttons = null, Variable timer = null,
            bool reset = false)
        {
            Get get = new Get()
            {
                IsWait       = isWait,
                Port         = port,
                SensorType   = sensor,
                IsComparsion = isComparasion,
                Comparasion  = comparasion,
                ValueCompare = valueCompare,
                ArrayCompare = arrayCompare,
                Buttons      = buttons,
                Timer        = timer,
                CanContinue  = false,
            };

            GlobalVariables.ExportData.Push(get);
        }
Пример #6
0
        /// <summary>
        /// Helper function for ParseConfig. Inserts an array of sensor objects in their correct place in sensors dictionary.
        /// </summary>
        /// <param name="stype">The type of sensors</param>
        /// <param name="slist">The list of sensors objects to be added</param>
        /// <param name="finalOrder">The order of these sensors objects in the overall associated sensor list</param>
        protected virtual void AddSensorsToList(SensorTypes stype, ArrayList slist, int finalOrder)
        {
            ArrayList DTlist = new ArrayList();

            if (!SensorsDictionary.TryGetValue(stype, out DTlist))
            {
                DTlist = new ArrayList(4);
                SensorsDictionary.Add(stype, DTlist);
            }

            if (DTlist.Capacity < (finalOrder + slist.Count))
            {
                DTlist.Capacity = ((finalOrder + slist.Count) / 4 + 1) * 4;     // increase capacity in steps of 4
            }
            DTlist.InsertRange(finalOrder, slist);

            if (stype == SensorTypes.DiffDrive)
            {
                cacheDrive = (DriveAdapter)((ListEntry)DTlist[0]).Adapter;
            }
            else if (stype == SensorTypes.ToneGenerator)
            {
                cacheTone = (ToneGeneratorAdapter)((ListEntry)DTlist[0]).Adapter;
            }
            else if (stype == SensorTypes.LEDArray)
            {
                cacheLED = (LEDArrayAdapter)((ListEntry)DTlist[0]).Adapter;
            }
        }
Пример #7
0
        static void Initialize()
        {
            Root = Path.Combine(Application.dataPath, "..");
            PersistentDataPath = Application.persistentDataPath;
            AssetBundle.UnloadAllAssetBundles(false);
            SensorPrefabs = RuntimeSettings.Instance.SensorPrefabs.ToList();

            if (SensorPrefabs.Any(s => s == null))
            {
                Debug.LogError("Null Sensor Prefab Detected - Check RuntimeSettings SensorPrefabs List for missing Sensor Prefab");
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#else
                // return non-zero exit code
                Application.Quit(1);
#endif
                return;
            }

            BridgePlugins.Load();
            LoadBuiltinAssets();
            LoadExternalAssets();
            Sensors = SensorTypes.ListSensorFields(SensorPrefabs);

            ParseConfigFile();
            if (!Application.isEditor)
            {
                ParseCommandLine();
            }
        }
Пример #8
0
        public void ReturnAllSensorTypes_When_Invoked()
        {
            //Arrange
            var contextOptions = new DbContextOptionsBuilder <SmartDormitoryDbContext>()
                                 .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                 .Options;

            using (var arrangeContext = new SmartDormitoryDbContext(contextOptions))
            {
                var sensorType = new SensorTypes
                {
                    IsDeleted = false,
                    Type      = "testType",
                    CreatedOn = DateTime.Now,
                };

                arrangeContext.SensorTypes.Add(sensorType);
                arrangeContext.SaveChanges();
            }

            // Act && Asert
            using (var assertContext = new SmartDormitoryDbContext(contextOptions))
            {
                var sensorService  = new SensorService(assertContext);
                var allSensorTypes = sensorService.GetAllTypes().ToList();

                Assert.AreEqual(1, allSensorTypes.Count);
            }
        }
Пример #9
0
 public SensorMask(SensorTypes[] sensorTypes)
 {
     foreach (SensorTypes sensorType in sensorTypes)
     {
         MaskValue |= 1UL << (UInt16)sensorType;
     }
 }
Пример #10
0
        private static void Initialize()
        {
            Root = Path.Combine(Application.dataPath, "..");
            PersistentDataPath = Application.persistentDataPath;

            ParseConfigFile();
            if (!Application.isEditor)
            {
                ParseCommandLine();
                CreateLockFile();
            }

            AssetBundle.UnloadAllAssetBundles(false);
            Sensors       = new List <SensorConfig>();
            SensorPrefabs = new List <SensorBase>();

            BridgePlugins.Load();
            LoadBuiltinAssets();
            LoadExternalAssets();
            Sensors = SensorTypes.ListSensorFields(SensorPrefabs);

            DatabaseManager.Init();

            ClientSettingsService csservice = new ClientSettingsService();

            if (string.IsNullOrEmpty(SimID))
            {
                SimID = csservice.GetOrMake().simid;
            }

            csservice.SetSimID(SimID);
        }
Пример #11
0
        public void TestEnumSensor()
        {
            var sensor  = new EnumSensor();
            var parameterCount = 2;
            var typeCount = 1;
            var valuesCount = 3;

            var config = SensorTypes.GetConfig(sensor);

            Assert.AreEqual("Enum", config.Name);
            Assert.AreEqual(typeCount, config.Types.Length);
            Assert.AreEqual("Simulator.Bridge.Data.ImageData", config.Types[0]);
            Assert.AreEqual(parameterCount, config.Parameters.Count);
            Assert.AreEqual("car", config.Parameters[0].Name);
            Assert.AreEqual("C", config.Parameters[0].DefaultValue);
            Assert.AreEqual("enum", config.Parameters[0].Type);
            Assert.AreEqual("truck", config.Parameters[1].Name);
            Assert.AreEqual("A", config.Parameters[1].DefaultValue);
            Assert.AreEqual("enum", config.Parameters[1].Type);
            Assert.AreEqual(valuesCount, config.Parameters[0].Values.Length);
            Assert.AreEqual("A", config.Parameters[0].Values[0]);
            Assert.AreEqual("B", config.Parameters[0].Values[1]);
            Assert.AreEqual("C", config.Parameters[0].Values[2]);
            Assert.False(config.Parameters.Exists(p => p.Name == "NotPresent"));
        }
Пример #12
0
 public double Auth(SensorTypes sensorType, double sensorValue)
 {
     switch (sensorType)
     {
         case SensorTypes.Temperature:
             if (sensorValue < MinTemp)
                 sensorValue = MinTemp;
             if (sensorValue > MaxTemp)
                 sensorValue = MaxTemp;
             break;
         case SensorTypes.Ph:
             if (sensorValue < MinPh)
                 sensorValue = MinPh;
             if (sensorValue > MaxPh)
                 sensorValue = MaxPh;
             break;
         case SensorTypes.Chlorine:
             if (sensorValue < MinChlor)
                 sensorValue = MinChlor;
             if (sensorValue > MaxChlor)
                 sensorValue = MaxChlor;
             break;
         case SensorTypes.Humidity:
             if (sensorValue < MinHum)
                 sensorValue = MinHum;
             if (sensorValue > MaxHum)
                 sensorValue = MaxHum;
             break;
         default:
             throw new ArgumentOutOfRangeException(nameof(sensorType), sensorType, null);
     }
     return sensorValue;
 }
Пример #13
0
 public SensorMask(SensorMask previousSensorMask, SensorTypes[] sensorTypes)
 {
     MaskValue = previousSensorMask.MaskValue;
     foreach (SensorTypes sensorType in sensorTypes)
     {
         MaskValue |= 1UL << (UInt16)sensorType;
     }
 }
Пример #14
0
 public override bool Initialize(SensorTypes sensorTypes)
 {
     if (this.queue == null)
     {
         this.queue = new NSOperationQueue();
     }
     this.RequestedSensors = sensorTypes;
     return(true);
 }
 public void RegisterDialog(SensorTypes sensorType, Type viewType, Type modelType)
 {
     _typeToDialogDictionary[sensorType] = new DialogSensorViewTypes()
     {
         ModelType = modelType,
         ViewType  = viewType
     };
     _factory?.RegisterModel(sensorType, modelType);
 }
Пример #16
0
        /// <summary>
        /// A method that populates a sensor object from an XML string
        /// </summary>
        /// <param name="xml">An input XML string that describes the sensor</param>
        public virtual void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xml);
            XmlNode iNode = dom.DocumentElement;

            if (iNode.Name == SENSOR_ELEMENT)
            {
                foreach (XmlAttribute iAttribute in iNode.Attributes)
                {
                    if (iAttribute.Name == CLASS_ATTRIBUTE)
                    {
                        this._Class = (SensorClasses)Enum.Parse(typeof(SensorClasses), iAttribute.Value, true);
                    }
                    else if (iAttribute.Name == TYPE_ATTRIBUTE)
                    {
                        this._Type = (SensorTypes)Enum.Parse(typeof(SensorTypes), iAttribute.Value, true);
                    }
                }

                foreach (XmlNode jNode in iNode.ChildNodes)
                {
                    foreach (XmlAttribute jAttribute in jNode.Attributes)
                    {
                        if ((jNode.Name == ID_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == SR_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                        {
                            this._SamplingRate = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == Receiver.RECEIVER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Receiver     = new Receivers.GenericReceiver();
                            this._Receiver._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == Decoder.DECODER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Decoder     = new Decoders.Accelerometers.GenericDecoder();
                            this._Decoder._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == LOCATION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                        {
                            this._Location = jAttribute.Value;
                        }
                        else if ((jNode.Name == DESCRIPTION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                        {
                            this._Description = jAttribute.Value;
                        }
                    }
                }
            }
        }
Пример #17
0
 public void RemoveSensor(SensorTypes sensorType)
 {
     foreach (var s in _sensors)
     {
         if (s.Type == sensorType)
         {
             _sensors.Remove(s);
             return;
         }
     }
 }
Пример #18
0
 public WISEObject CreateObject(SensorTypes sensorType, ObjectHandle hObject)
 {
     switch (sensorType)
     {
         case SensorTypes.lcd:   return new EntityEquipmentSensorCBRNLCD(_sink, _hDatabase, hObject);
         case SensorTypes.ap2ce: return new EntityEquipmentSensorCBRNAP2Ce(_sink, _hDatabase, hObject);
         case SensorTypes.raid:  return new EntityEquipmentSensorCBRNRAID(_sink, _hDatabase, hObject);
         case SensorTypes.i28:   return new EntityEquipmentSensorCBRNI28(_sink, _hDatabase, hObject);
         case SensorTypes.i27:   return new EntityEquipmentSensorCBRNI27(_sink, _hDatabase, hObject);
     }
     throw new NotImplementedException();
 }
Пример #19
0
        public MonitoringSensorViewModel(MonitoringSensorUpdate sensorUpdate, MonitoringNodeBase parent = null)
        {
            _lastStatusUpdate = DateTime.Now;
            Name    = sensorUpdate.Name;
            _parent = parent;
            Product = sensorUpdate.Product;

            Status        = sensorUpdate.Status;
            _sensorType   = sensorUpdate.SensorType;
            _path         = ConvertPathToString(sensorUpdate.Path);
            ShortValue    = sensorUpdate.ShortValue;
            _sensorUpdate = sensorUpdate;
        }
Пример #20
0
        static void Initialize()
        {
            Root = Path.Combine(Application.dataPath, "..");
            PersistentDataPath = Application.persistentDataPath;
            Sensors            = SensorTypes.ListSensorFields(RuntimeSettings.Instance?.SensorPrefabs);
            Bridges            = BridgeTypes.GetBridgeTypes();

            ParseConfigFile();
            if (!Application.isEditor)
            {
                ParseCommandLine();
            }
        }
Пример #21
0
        protected Sensor(SensorTypes type, object owner, TShape shape, uint groups, uint affects, bool isCompound)
        {
            Type    = type;
            Groups  = groups;
            Affects = affects;

            // Note that sensor owner is allowed to be null (useful for manually creating debug sensors, but might be
            // applicable in finished games too).
            Owner      = owner;
            Shape      = shape;
            IsEnabled  = true;
            IsCompound = isCompound;
            Contacts   = new List <Sensor <TSensor, TShape, TShapeType, TSpace, TPosition> >();
        }
Пример #22
0
		public static string SignForType(SensorTypes type)
		{
			switch (type)
			{
			case SensorTypes.Temperature:
				return "°C";
			case SensorTypes.Humidity:
				return "%";
			case SensorTypes.Chlorine:
				return "ppm";
			default:
				return "";
			}
		}
Пример #23
0
        public void AddSensor(SensorTypes sensorType)
        {
            foreach (var s in _sensors)
            {
                if (s.Type == sensorType)
                {
                    return;
                }
            }

            var sensor = Create(sensorType);

            _sensors.Add(sensor);
        }
Пример #24
0
        static void Initialize()
        {
            Root = Path.Combine(Application.dataPath, "..");
            PersistentDataPath = Application.persistentDataPath;
            SensorPrefabs      = LoadSensorPlugins();
            Controllables      = LoadControllablePlugins();
            Sensors            = SensorTypes.ListSensorFields(SensorPrefabs);
            Bridges            = BridgeTypes.GetBridgeTypes();

            ParseConfigFile();
            if (!Application.isEditor)
            {
                ParseCommandLine();
            }
        }
Пример #25
0
        protected Sensor(SensorTypes type, object owner, int groups, int affects, bool isCompound,
                         Shape3D shape = null)
        {
            Debug.Assert(owner != null, "Owner can't be null.");

            this.shape = shape;

            Type       = type;
            Groups     = groups;
            Affects    = affects;
            Owner      = owner;
            IsEnabled  = true;
            IsCompound = isCompound;
            Contacts   = new List <Sensor>();
        }
Пример #26
0
        public DroidSensors(SensorTypes sensorTypes)
        {
            this.sensorManager  = Application.Context.GetSystemService(Context.SensorService) as SensorManager;
            this.sensorListener = new DroidSensorListener();

            // Accelerometer
            if (sensorTypes.HasFlag(SensorTypes.Accelerometer))
            {
                this.accelerometer = this.sensorManager.GetDefaultSensor(SensorType.Accelerometer);
            }
            // Gyroscope
            if (sensorTypes.HasFlag(SensorTypes.Gyroscope))
            {
                this.gyroscope = this.sensorManager.GetDefaultSensor(SensorType.Gyroscope);
            }
        }
Пример #27
0
 public override bool Initialize(SensorTypes sensorTypes)
 {
     if (!this.Initialized)
     {
         // Accelerometer
         if (sensorTypes.HasFlag(SensorTypes.Accelerometer))
         {
             this.accelerometer = this.sensorManager.GetDefaultSensor(SensorType.Accelerometer);
         }
         // Gyroscope
         if (sensorTypes.HasFlag(SensorTypes.Gyroscope))
         {
             this.gyroscope = this.sensorManager.GetDefaultSensor(SensorType.Gyroscope);
         }
         this.Initialized = true;
         return(true);
     }
     return(false);
 }
Пример #28
0
        private ICharacterSensor Create(SensorTypes sensorType)
        {
            switch (sensorType)
            {
            case SensorTypes.Sight:
                return(new SightSensor());

            case SensorTypes.MeleeRange:
                return(new MeleeRangeSensor());

            case SensorTypes.FieldOfView:
                return(new FieldOfViewSensor());

            case SensorTypes.SpeelCastRange:
                return(new SpellCastRangeSensor());
            }

            return(null);
        }
Пример #29
0
        public void TestStringSensor()
        {
            var sensor = new StringSensor();
            var parameterCount = 2;
            var typeCount = 1;

            var config = SensorTypes.GetConfig(sensor);

            Assert.AreEqual("String", config.Name);
            Assert.AreEqual(typeCount, config.Types.Length);
            Assert.AreEqual("Simulator.Bridge.Data.ImageData", config.Types[0]);
            Assert.AreEqual(parameterCount, config.Parameters.Count);
            Assert.AreEqual("Help", config.Parameters[0].Name);
            Assert.AreEqual("helping", config.Parameters[0].DefaultValue);
            Assert.AreEqual("string", config.Parameters[0].Type);
            Assert.AreEqual("LG", config.Parameters[1].Name);
            Assert.AreEqual(null, config.Parameters[1].DefaultValue);
            Assert.AreEqual("string", config.Parameters[1].Type);
            Assert.False(config.Parameters.Exists(p => p.Name == "NotPresent"));
        }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DHT11"/> class.
 /// </summary>
 /// <param name="datatPin">The datat pin.</param>
 /// <param name="sensor">The sensor.</param>
 /// <exception cref="System.ArgumentException">Parameter cannot bet null.;dataPin</exception>
 public DHT11(GpioPin datatPin, SensorTypes sensor)
 {
     if (datatPin != null)
     {
         _dataPin = datatPin;
         _secondsSinceLastRead = 0D;
         _firstReading         = true;
         _data       = new UInt32[6];
         _sensorType = sensor;
         //Init the data pin
         _dataPin.SetDriveMode(GpioPinDriveMode.Input);
         _dataPin.Write(GpioPinValue.High);
         _firstReading         = true;
         _secondsSinceLastRead = 0;
     }
     else
     {
         throw new ArgumentException("Parameter cannot bet null.", "dataPin");
     }
 }
Пример #31
0
        public void TestColorSensor()
        {
            var sensor = new ColorSensor();
            var parameterCount = 2;
            var typeCount = 1;

            var config = SensorTypes.GetConfig(sensor);

            Assert.AreEqual("Color", config.Name);
            Assert.AreEqual(typeCount, config.Types.Length);
            Assert.AreEqual("Simulator.Bridge.Data.ImageData", config.Types[0]);
            Assert.AreEqual(parameterCount, config.Parameters.Count);
            Assert.AreEqual("picture", config.Parameters[0].Name);
            Assert.AreEqual("#FF00FFFF", config.Parameters[0].DefaultValue);
            Assert.AreEqual("color", config.Parameters[0].Type);
            Assert.AreEqual("space", config.Parameters[1].Name);
            Assert.AreEqual("#00000000", config.Parameters[1].DefaultValue);
            Assert.AreEqual("color", config.Parameters[1].Type);
            Assert.False(config.Parameters.Exists(p => p.Name == "NotPresent"));
        }
Пример #32
0
        public void TestIntSensor()
        {
            var sensor = new IntSensor();
            var parameterCount = 2;
            var typeCount = 1;

            var config = SensorTypes.GetConfig(sensor);

            Assert.AreEqual("Int", config.Name);
            Assert.AreEqual(typeCount, config.Types.Length);
            Assert.AreEqual("Simulator.Bridge.Data.ImageData", config.Types[0]);
            Assert.AreEqual(parameterCount, config.Parameters.Count);
            Assert.AreEqual("year", config.Parameters[0].Name);
            Assert.AreEqual(2019, config.Parameters[0].DefaultValue);
            Assert.AreEqual("int", config.Parameters[0].Type);
            Assert.AreEqual("LG", config.Parameters[1].Name);
            Assert.AreEqual(0, config.Parameters[1].DefaultValue);
            Assert.AreEqual("int", config.Parameters[1].Type);
            Assert.False(config.Parameters.Exists(p => p.Name == "NotPresent"));
        }
Пример #33
0
        public void TestBoolSensor()
        {
            var sensor = new BoolSensor();
            var parameterCount = 2;
            var typeCount = 1;

            var config = SensorTypes.GetConfig(sensor);

            Assert.AreEqual("Bool", config.Name);
            Assert.AreEqual(typeCount, config.Types.Length);
            Assert.AreEqual("Simulator.Bridge.Data.ImageData", config.Types[0]);
            Assert.AreEqual(parameterCount, config.Parameters.Count);
            Assert.AreEqual("happy", config.Parameters[0].Name);
            Assert.AreEqual(true, config.Parameters[0].DefaultValue);
            Assert.AreEqual("bool", config.Parameters[0].Type);
            Assert.AreEqual("duckie", config.Parameters[1].Name);
            Assert.AreEqual(false, config.Parameters[1].DefaultValue);
            Assert.AreEqual("bool", config.Parameters[1].Type);
            Assert.False(config.Parameters.Exists(p => p.Name == "NotPresent"));
        }
Пример #34
0
        private static void Initialize()
        {
            Root = Path.Combine(Application.dataPath, "..");
            PersistentDataPath = Application.persistentDataPath;

            ParseConfigFile();
            if (!Application.isEditor)
            {
                ParseCommandLine();
                CreateLockFile();
            }

            AssetBundle.UnloadAllAssetBundles(false);
            Sensors       = new List <SensorConfig>();
            SensorPrefabs = new List <SensorBase>();
            if (SensorPrefabs.Any(s => s == null))
            {
                Debug.LogError("!!! Null Sensor Prefab Detected - Check RuntimeSettings SensorPrefabs List for missing Sensor Prefab");
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#else
                Application.Quit(1); // return non-zero exit code
#endif
            }

            BridgePlugins.Load();
            LoadBuiltinAssets();
            LoadExternalAssets();
            Sensors = SensorTypes.ListSensorFields(SensorPrefabs);

            DatabaseManager.Init();

            ClientSettingsService csservice = new ClientSettingsService();
            if (string.IsNullOrEmpty(SimID))
            {
                SimID = csservice.GetOrMake().simid;
            }

            csservice.SetSimID(SimID);
        }
Пример #35
0
        public void TestManyDataSensor()
        {
            var sensor = new ManyDataSensor();
            var parameterCount = 1;
            var expectedTypes = new []
            {
                typeof(ImageData),
                typeof(PointCloudData),
                typeof(Detected3DObjectArray),
                typeof(Detected3DObjectData),
            };

            var config = SensorTypes.GetConfig(sensor);

            Assert.AreEqual("ManyData", config.Name);
            Assert.AreEqual(expectedTypes.Length, config.Types.Length);
            for (int i=0; i<expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes[i].ToString(), config.Types[i], $"Wrong type, expected {expectedTypes[i]}, got {config.Types[i]}");
            }
            Assert.AreEqual(parameterCount, config.Parameters.Count);
            Assert.AreEqual("data", config.Parameters[0].Name);
            Assert.AreEqual(2, config.Parameters[0].DefaultValue);
        }
Пример #36
0
 /// <summary>
 /// A constructor that initializes the sensor type and class
 /// </summary>
 /// <param name="type"></param>
 /// <param name="classname"></param>
 public Sensor(SensorTypes type,SensorClasses classname)
 {
     this._Class = classname;
     this._Type = type;
     this._SamplingRate = 0;
     this._Saving = true;
 }
Пример #37
0
 public SensorMask(SensorMask previousSensorMask, SensorTypes sensorType)
 {
     MaskValue = previousSensorMask.MaskValue;
     MaskValue |= 1UL << (UInt16)sensorType;
 }
Пример #38
0
        /// <summary>
        /// A method that populates a sensor object from an XML string
        /// </summary>
        /// <param name="xml">An input XML string that describes the sensor</param>
        public virtual void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();
            dom.LoadXml(xml);
            XmlNode iNode = dom.DocumentElement;
            if (iNode.Name == SENSOR_ELEMENT)
            {

                foreach (XmlAttribute iAttribute in iNode.Attributes)
                {
                    if (iAttribute.Name == CLASS_ATTRIBUTE)
                        this._Class =  (SensorClasses)Enum.Parse(typeof(SensorClasses), iAttribute.Value,true);
                    else if (iAttribute.Name == TYPE_ATTRIBUTE)
                        this._Type = (SensorTypes)Enum.Parse(typeof(SensorTypes), iAttribute.Value,true);
                }

                foreach (XmlNode jNode in iNode.ChildNodes)
                {
                    foreach (XmlAttribute jAttribute in jNode.Attributes)
                    {
                        if ((jNode.Name == ID_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                            this._ID = Convert.ToInt32(jAttribute.Value);
                        else if ((jNode.Name == SR_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                            this._SamplingRate = Convert.ToInt32(jAttribute.Value);
                        else if ((jNode.Name == Receiver.RECEIVER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Receiver = new Receivers.GenericReceiver();
                            this._Receiver._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == Decoder.DECODER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Decoder = new Decoders.Accelerometers.GenericDecoder();
                            this._Decoder._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == LOCATION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                            this._Location = jAttribute.Value;
                        else if ((jNode.Name == DESCRIPTION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                            this._Description = jAttribute.Value;

                    }
                }
            }
        }
Пример #39
0
 public SensorMask(SensorTypes sensorType1, SensorTypes sensorType2, SensorTypes sensorType3)
 {
     MaskValue |= (1UL << (UInt16)sensorType1) | (1UL << (UInt16)sensorType2) | (1UL << (UInt16)sensorType3);
 }
Пример #40
0
 public SensorMask(SensorTypes sensorType)
 {
     MaskValue |= 1UL << (UInt16)sensorType;
 }
Пример #41
0
 public void SetSensorType(SensorTypes sensorType)
 {
     this.MaskValue = 1UL << (UInt16)sensorType;
 }
Пример #42
0
 public void RemoveSensorType(SensorTypes sensorType)
 {
     this.MaskValue = this.MaskValue & ~(1UL << (UInt16)sensorType);
 }
Пример #43
0
 public Boolean HasASensor(SensorTypes sensorType)
 {
     return (MaskValue & (1UL << (UInt16)sensorType)) != 0UL;
 }
Пример #44
0
 public void AddSensorType(SensorTypes sensorType)
 {
     this.MaskValue = this.MaskValue | 1UL << (UInt16)sensorType;
 }
Пример #45
0
 private static Tuple<SensorTypes, List<double>> GetData(List<Tuple<SensorTypes, double>> dataFromDb, SensorTypes sensorType)
 {
     var tempList = new List<double>();
     foreach (var tuple in dataFromDb)
     {
         tempList.Add(tuple.Item2);
     }
     return new Tuple<SensorTypes, List<double>>(sensorType, tempList);
 }
Пример #46
0
		// Graph drawing

		private Tuple<double, double> DrawGraph(UIView view, List<double> values, SensorTypes type)
		{
			var bounds = GraphBounds (values, (type == SensorTypes.Chlorine || type == SensorTypes.Ph));
			var points = GraphPoints (values, bounds, view);
			var numberOfPoints = points.Count;

			if (numberOfPoints == 0)
				return bounds;

			var path = new UIBezierPath ();
			path.MoveTo (points[0]);

			for (var i = 1; i < numberOfPoints; i++) {
				path.AddLineTo (points[i]);
			}

			var layer = new CAShapeLayer ();
			layer.Path = path.CGPath;
			layer.StrokeColor = UIColor.White.CGColor;
			layer.LineWidth = 2;
			layer.FillColor = UIColor.Clear.CGColor;

			view.Layer.Sublayers = null;
			view.Layer.AddSublayer (layer);

			return bounds;
		}
 public FailedDeviceSettings(int deviceId, float deviceGradient, SensorTypes type)
 {
     SensorType = type;
     FailedDeviceId = deviceId;
     FailedDeviceGradient = deviceGradient;
 }