예제 #1
0
        private void TimeRead_Elapsed(object sender, Timer.ElapsedEventArgs e)
        {
            var t = sender as Timer.Timer;

            t.Stop();
            if (_client.IsConnect)
            {
                foreach (var point in _points.BoolPoints)
                {
                    point.Value = _client.ReadBools(point.Address, (ushort)point.Length);
                }
                //foreach (var point in points.BytePoints)
                //{
                //    var devicePoint = point as DevicePoint<byte>;
                //    client.ReadBytes(devicePoint.Address, (ushort)devicePoint.Length);
                //}
                foreach (var point in _points.UshortPoints)
                {
                    point.Value = _client.ReadUShorts(point.Address, (ushort)point.Length);
                }
                foreach (var point in _points.ShortPoints)
                {
                    point.Value = _client.ReadShorts(point.Address, (ushort)point.Length);
                }
                foreach (var point in _points.IntPoints)
                {
                    point.Value = _client.ReadInts(point.Address, (ushort)point.Length);
                }
                foreach (var point in _points.UintPoints)
                {
                    point.Value = _client.ReadUInts(point.Address, (ushort)point.Length);
                }
                foreach (var point in _points.FloatPoints)
                {
                    point.Value = _client.Readfloats(point.Address, (ushort)point.Length);
                }
                //foreach (var point in _points.StringPoints)
                //{
                //    var devicePoint = point as DevicePoint<string>;
                //    devicePoint.Value= _client.ReadStrings(devicePoint.Address, (ushort)devicePoint.Length);
                //}
            }
            else
            {
                _client.Connect();
            }
            t.Start();
        }