Ejemplo n.º 1
0
        private void EquipActuator(int?actuatorId, int?sensorId)
        {
            if (_foi.Places.Exists(p => p.Devices.Exists(d => d.UniqueIdentifier == actuatorId && d.DeviceType == DeviceType.Actuator)))
            {
                Place actuatorPlace = _foi.Places.Find(p => p.Devices.Exists(d => d.UniqueIdentifier == actuatorId && d.DeviceType == DeviceType.Actuator));
                Place sensorPlace   = _foi.Places.Find(p => p.Devices.Exists(d => d.UniqueIdentifier == sensorId && d.DeviceType == DeviceType.Sensor));

                if (actuatorPlace == sensorPlace)
                {
                    Actuator actuator = (Actuator)actuatorPlace.Devices.Find(d => d.UniqueIdentifier == actuatorId && d.DeviceType == DeviceType.Actuator);
                    Sensor   sensor   = (Sensor)sensorPlace.Devices.Find(d => d.UniqueIdentifier == sensorId && d.DeviceType == DeviceType.Sensor);

                    if (!actuator.GetChildren().Contains(sensor))
                    {
                        actuator.AddChild(sensor);
                        sensor.AddParent(actuator);
                    }
                    else
                    {
                        Data.Add("Aktuator (" + actuatorId + ") vec sadrzi senzor (" + sensorId + ")!");
                    }
                }
                else
                {
                    Data.Add("Aktuator (" + actuatorId + ") i/ili senzor (" + sensorId + ") se ne nalaze u (istoj) prostoriji pa ih se ne moze spariti!");
                }
            }
            else
            {
                Data.Add("Aktuator sa ID-em: " + actuatorId + " nije definiran ni za jedno mjesto!");
            }
        }