Exemple #1
0
        public DatapointMonitor(ProjectDatapointTask dataPointTask, DataPointEvaluatorProvider evaluatorProvider, UniversalIotConnector connector, ILogger logger, EmbeddedDriverModule edm)
        {
            if (dataPointTask == null)
            {
                throw new ArgumentNullException("dataPointTask");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (connector == null)
            {
                throw new ArgumentNullException("connector");
            }
            if (edm == null)
            {
                throw new ArgumentNullException("edm");
            }

            _dataPointTask     = dataPointTask;
            _evaluatorProvider = evaluatorProvider;
            _connector         = connector;
            _logger            = logger;
            _edm = edm;
            (new Thread(Target)).Start();
        }
Exemple #2
0
        private void AddDistinctCommand(List <CommandDto> commands, ProjectDatapointTask dataPoint)
        {
            IEnumerable <CommandDto> cmds = GetCommandsOf(dataPoint);

            foreach (var cmd in cmds)
            {
                if (commands.All(c => c.Command != cmd.Command))
                {
                    commands.Add(cmd);
                }
            }
        }
Exemple #3
0
        private Sensor GetSensorsOf(ProjectDatapointTask dataPoint)
        {
            Sensor sensor = new Sensor
            {
                DataType    = GetM2mgoDataTypeOf(dataPoint.Definition.DataType),
                Description = dataPoint.Definition.Uri,
                Name        = dataPoint.Definition.Label,
                SensorKey   = GetKeyFrom(dataPoint.Definition),
                Metadata    = new SensorMetadataViewModel
                {
                    ErrorThreshold = dataPoint.MetaData.ErrorThreshold,
                    Tags           = new [] { dataPoint.MetaData.Tags },
                    IsInverseThresholdEvaluation = dataPoint.MetaData.IslnverseThresholdEvaluation,
                    Max = dataPoint.MetaData.ExpectedMaximum,
                    Min = dataPoint.MetaData.ExpectedMinimum,
                    WarningThreshold = dataPoint.MetaData.WarningThreshold,
                }
            };

            return(sensor);
        }
Exemple #4
0
        private IEnumerable <CommandDto> GetCommandsOf(ProjectDatapointTask dataPoint)
        {
            List <CommandDefinition> commandDefinitions;

            if (_guidUicSensorCommandMap.TryGetValue(dataPoint.Definition.Id, out commandDefinitions))
            {
                IEnumerable <CommandDto> commandDtos = commandDefinitions.Select(c => new CommandDto
                {
                    Command  = c.Id + "." + c.Command,
                    Name     = c.Label,
                    Metadata = new CommandMetadataViewModel
                    {
                        RelatedToSensorKey = GetKeyFrom(c.RelatedDatapoint),
                        Tags = c.Tags
                    }
                }).ToArray();
                return(commandDtos);
            }

            return(new CommandDto[0]);
        }
Exemple #5
0
 public void SetDatapointCallback(ProjectDatapointTask datapointTask, Action <DatapointValue> callback)
 {
     // no need for callbacks
 }
Exemple #6
0
        private void UdpateSensorAndCorrespondingCommands(BlueprintDto exisingBlueprint, ProjectDatapointTask datapoint)
        {
            Sensor sensor         = GetSensorsOf(datapoint);
            Sensor existingSensor = exisingBlueprint.Sensors.SingleOrDefault(s => s.SensorKey == sensor.SensorKey);

            if (existingSensor == null)
            {
                exisingBlueprint.Sensors.Add(sensor);
            }
            else
            {
                existingSensor.Metadata = sensor.Metadata;
            }
            AddDistinctCommand(exisingBlueprint.Commands, datapoint);
        }
Exemple #7
0
 public void SetDatapointCallback(ProjectDatapointTask datapointTask, Action <DatapointValue> callback)
 {
     _action = callback;
 }
Exemple #8
0
 public void SetDatapointCallback(ProjectDatapointTask datapointTask, Action <DatapointValue> callback)
 {
     // nothing to do yet
 }