コード例 #1
0
        public DiscretChannel(DiscretChannelConfiguration configuration, int[] data, int run)
        {
            this._run      = run;
            _configuration = configuration;
            _data          = data;

            this.Values  = data.Select(o => o != 0).ToArray();
            this.IsEmpty = data.All(o => o == 0);
        }
コード例 #2
0
        public void AddDiscret(int wordIndex, int byteIndex, string name)
        {
            var conf = new DiscretChannelConfiguration(name, 0);

            _discetChannelDescriptions.Add(new DiscetChannelDescription(conf, GetDiscretArray(_countingArray[wordIndex], byteIndex)));
        }
コード例 #3
0
 public DiscetChannelDescription(DiscretChannelConfiguration configuration, ushort[] data)
 {
     _configuration = configuration;
     _data          = data;
 }
コード例 #4
0
        public void Load(string fileName, int encoding)
        {
            fileName = Path.ChangeExtension(fileName, "cfg");
            string[] strings = File.ReadAllLines(fileName);

            if (encoding != 0)
            {
                strings = File.ReadAllLines(fileName, Encoding.GetEncoding(encoding));
            }

            string[] head = strings[0].Split(new[] { ',' }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
            if (head.Length >= 2)
            {
                this._deviceName = head[0];
                this._deviceId   = head[1];
            }

            string[] channels = strings[1].Split(new[] { ',' }, int.MaxValue);

            if (channels.Length == 3)
            {
                this._allChannelsCount = int.Parse(channels[0]);
                if (channels[1].Last() == ANALOG_CHANNEL)
                {
                    string analog = channels[1].TrimEnd(new[] { ANALOG_CHANNEL });
                    this._analogChannels = int.Parse(analog);
                }

                if (channels[2].Last() == DISCRET_CHANNEL)
                {
                    string discret = channels[2].TrimEnd(new[] { DISCRET_CHANNEL });
                    this._discretChannels = int.Parse(discret);
                }
                if (this.AllChannelsCount != this.AnalogChannels + this.DiscretChannels)
                {
                    throw new FileLoadException(string.Format("Ошибка в файле {0}, строка 2", fileName));
                }
            }
            else
            {
                throw new FileLoadException(string.Format("Ошибка в файле {0}, строка 2", fileName));
            }
            int i = 2;

            for (; i < this.AnalogChannels + 2; i++)
            {
                AnalogChannelConfiguration a = new AnalogChannelConfiguration(strings[i]);
                this._analogChannelConfigurations.Add(a);
            }

            for (; i < this.AnalogChannels + this.DiscretChannels + 2; i++)
            {
                DiscretChannelConfiguration a = new DiscretChannelConfiguration(strings[i]);
                this._discretChannelConfigurations.Add(a);
            }

            this._frequency = (int)double.Parse(strings[i], CultureInfo.InvariantCulture);
            i++;
            this._samplingCount = int.Parse(strings[i]);
            i++;
            for (int j = 0; j < this._samplingCount; j++)
            {
                channels           = strings[i].Split(new[] { ',' });
                this._samplingRate = (int)double.Parse(channels[0], CultureInfo.InvariantCulture);
                this._size         = int.Parse(channels[1]);
                i++;
            }
            this._start = strings[i];
            i++;
            this._run = strings[i];
            i++;
            this._encodingStr = strings[i];
            this.CalcRunOsc();
        }
コード例 #5
0
 internal bool IsEqual(DiscretChannelConfiguration discretChannelConfiguration)
 {
     return(this._name == discretChannelConfiguration._name &
            this._default == discretChannelConfiguration._default);
 }