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(); }
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); } } }
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); }
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]); }
public void SetDatapointCallback(ProjectDatapointTask datapointTask, Action <DatapointValue> callback) { // no need for callbacks }
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); }
public void SetDatapointCallback(ProjectDatapointTask datapointTask, Action <DatapointValue> callback) { _action = callback; }
public void SetDatapointCallback(ProjectDatapointTask datapointTask, Action <DatapointValue> callback) { // nothing to do yet }