Exemple #1
0
        public List <MappingRule> GetMappingRules()
        {
            if ((ChannelIds == null) || (ChannelIds.Count == 0))
            {
                return(null);
            }
            CanonDataContext   db   = Cdb.Instance;
            List <MappingRule> maps = db.MappingRules.Where(m => ChannelIds.Contains(m.ChannelId)).ToList();

            return(maps);
        }
Exemple #2
0
        /// <summary>
        /// Adds the channel.
        /// </summary>
        /// <param name="channelId">The channel identifier.</param>
        /// <param name="mnemonic">The mnemonic.</param>
        /// <param name="unit">The unit.</param>
        /// <param name="dataType">The data type.</param>
        /// <param name="nullValue">The null value.</param>
        public void AddChannel(long channelId, string mnemonic, string unit, string dataType, string nullValue = null)
        {
            if (Mnemonics.Any(x => x.EqualsIgnoreCase(mnemonic)))
            {
                return;
            }

            ChannelIds.Add(channelId);
            Mnemonics.Add(mnemonic);
            Units.Add(unit);
            DataTypes.Add(dataType);
            NullValues.Add(nullValue);
        }
Exemple #3
0
        public async ValueTask ExecuteAsync(IConsole console)
        {
            var channels = ChannelIds?.UnJoin('|').ToArray();

            // make a new app context with a custom region defined
            var appCtx = new PipeAppCtx(AppCtx)
            {
                CustomRegion = () => Rand.Choice(Regions)
            };

            // run the work using the pipe entry point, forced to be local
            PipeAppCfg.Location = PipeRunLocation.Local;
            var pipeCtx = new PipeCtx(PipeAppCfg, appCtx, PipeCtx.Store, PipeCtx.Log);
            await pipeCtx.Run((YtCollector d) => d.Collect(PipeArg.Inject <ILogger>(), ForceUpdate, false, channels, PipeArg.Inject <CancellationToken>()));
        }
Exemple #4
0
        /// <summary>
        /// Appends the index and data values for the specified channel identifier.
        /// </summary>
        /// <param name="channelId">The channel identifier.</param>
        /// <param name="indexes">The index values.</param>
        /// <param name="value">The data value.</param>
        public void Append(long channelId, IList <object> indexes, object value)
        {
            var primaryIndex = indexes.First();
            List <List <object> > record;

            // Check if primary index has been added before
            if (!_recordsByIndex.TryGetValue(primaryIndex, out record))
            {
                record = new List <List <object> >()
                {
                    new List <object>()
                    {
                        primaryIndex
                    },
                    new List <object>()
                };

                _records.Add(record);
                _recordsByIndex[primaryIndex] = record;
            }

            var position       = ChannelIds.IndexOf(channelId);
            var channelIndexes = record[0];
            var channelValues  = record[1];

            // Secondary indexes
            if (indexes.Count > 1)
            {
                channelIndexes.AddRange(indexes);
            }

            // Ensure available channel value slots
            for (int i = channelValues.Count; i < ChannelIds.Count; i++)
            {
                channelValues.Add(null);
            }

            // Channel value
            channelValues[position] = value;
        }
Exemple #5
0
 /// <summary>
 ///     Adds a channel.
 /// </summary>
 /// <param name="channel">The channel.</param>
 public void AddChannel(int channel)
 {
     ChannelIds.Insert(0, channel);
 }