private List <(ValueTypeStateless valueTypeStateless, Signal signal)> GetListOfValuesToSetInEbo(IotEdgeMessage iotEdgeMessage)
        {
            var toSet = new List <(ValueTypeStateless valueTypeStateless, Signal signal)>();

            foreach (var option in iotEdgeMessage.Actuations)
            {
                var theSignalToSet = Signals.FirstOrDefault(a => a.DatabasePath == $"{iotEdgeMessage.DeviceId}/{option.ActuatorId}");

                if (theSignalToSet == null)
                {
                    Logger.LogInfo(LogCategory.Processor, this.Name, $"{iotEdgeMessage.DeviceId}/{option.ActuatorId} does not exist in the list of monitored values. Skipping.");
                    if (iotEdgeMessage.Exceptions == null)
                    {
                        iotEdgeMessage.Exceptions = new List <ExceptionElement>();
                    }
                    iotEdgeMessage.Exceptions.Add(new ExceptionElement
                    {
                        ExceptionTime = DateTimeOffset.UtcNow,
                        Exception     = $"{iotEdgeMessage.DeviceId}/{option.ActuatorId} does not exist in the list of monitored values. Please make sure that the configuration CSV file contains this point",
                        Retry         = 1,
                        SensorId      = option.ActuatorId
                    });
                }
                else
                {
                    toSet.Add(new ValueTuple <ValueTypeStateless, Signal>(
                                  new ValueTypeStateless {
                        Id = theSignalToSet.EwsIdForWrite, Value = option.Value
                    },
                                  theSignalToSet));
                }
            }
            return(toSet);
        }
Exemple #2
0
        private void AddUpdatedValuesToMessage(List <Observation> observations, string devicePath, List <SubscriptionResultItem> pointsToAdd, List <string> pointsMonitoredBySub, bool sendAdditionalProperties = false)
        {
            foreach (var eventz in pointsToAdd)
            {
                var signal = Signals.FirstOrDefault(a => a.EwsId == eventz.ValueItemChangeEvent.Id);
                if (signal == null)
                {
                    Logger.LogInfo(LogCategory.Processor, this.Name, $"Signal with EWS ID of {eventz.ValueItemChangeEvent.Id} does not exist.. Skipping this..");
                    continue;
                }

                signal.Value          = eventz.ValueItemChangeEvent.Value;
                signal.LastUpdateTime = eventz.ValueItemChangeEvent.TimeStamp.ToUniversalTime();
                if (signal.SendOnUpdate)
                {
                    HandleAddingToObservationsList(observations, signal, sendAdditionalProperties);
                }
            }

            Signals = Signals;

            foreach (var signal in Signals.Where(a => pointsMonitoredBySub.Contains(a.EwsId) && a.DatabasePath.Remove(a.DatabasePath.LastIndexOf('/')) == devicePath))
            {
                if (signal.LastSendTime != null && signal.LastSendTime.Value.AddSeconds(signal.SendTime) > DateTimeOffset.Now)
                {
                    continue;
                }
                if (observations.All(a => $"{devicePath}/{a.SensorId}" != signal.DatabasePath))
                {
                    HandleAddingToObservationsList(observations, signal, sendAdditionalProperties);
                }
            }
        }
        public SignalDefenition GetSignalDefenition(string name)
        {
            var defenition = Signals.FirstOrDefault(x => x.Name == name);

            defenition = defenition ?? Document.Entity.Ports.FirstOrDefault(x => x.Name == name);
            return(defenition);
        }
Exemple #4
0
        public void RemoveSignal(int index, TradeType tradeType)
        {
            var signal = Signals.FirstOrDefault(iSignal => iSignal.Index == index && iSignal.TradeType == tradeType);

            if (signal != null)
            {
                Signals.Remove(signal);
            }
        }
Exemple #5
0
        /// <summary>
        /// Read the signal matching the given name.
        /// </summary>
        /// <param name="aContains"></param>
        /// <returns></returns>
        public Signal ReadSignal(string aMatch)
        {
            var signal = Signals.FirstOrDefault(s => s.Label.Value.Equals(aMatch));

            if (signal == null)
            {
                return(null);
            }

            iReader.ReadSignal(Header, signal);
            return(signal);
        }