Exemplo n.º 1
0
 internal bool IsEqual(AnalogChannelConfiguration analogChannelConfiguration)
 {
     return(analogChannelConfiguration._number == this._number &
            analogChannelConfiguration._name == this._name &
            analogChannelConfiguration._phase == this._phase &
            analogChannelConfiguration._component == this._component &
            analogChannelConfiguration._measure == this._measure &
            analogChannelConfiguration._a == this._a &
            analogChannelConfiguration._b == this._b &
            analogChannelConfiguration._skew == this._skew &
            analogChannelConfiguration._min == this._min &
            analogChannelConfiguration._max == this._max &
            analogChannelConfiguration._samplingRate == this._samplingRate);
 }
Exemplo n.º 2
0
        public void AddAnalog(int wordIndex, string name, string measure, double a, double b)
        {
            var conf = new AnalogChannelConfiguration(name, measure, a, b);

            _analogChannelDescriptions.Add(new AnalogChannelDescription(conf, _countingArray[wordIndex]));
        }
Exemplo n.º 3
0
 public AnalogChannelDescription(AnalogChannelConfiguration configuration, int[] data)
 {
     _configuration = configuration;
     _data          = data;
 }
Exemplo n.º 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();
        }