public virtual async Task <bool> RaiseDigitalSwitchStatus(int deviceNumber, int itemCount, int switchNumber, SwitchStatus swtichStatus)
        {
            var sendCommand = new AutoUploadSwitchStatusCommand(deviceNumber, itemCount, switchNumber);
            var buffer      = sendCommand.GetRaiseSwitchData(swtichStatus);

            TLAutoDeviceSerialPort.RaiseDataReceived(buffer);
            return(await Task.Factory.StartNew(() => true));
        }
Пример #2
0
        public async Task <IEnumerable <SwitchItem> > QuerySwitchStatusWithAutoNotification(int deviceNumber, int itemCount, int[] querySwitchNumbers, int queryTime)
        {
            var tasks = new List <Task <SwitchItem> >();

            Parallel.ForEach(querySwitchNumbers, switchNumber =>
            {
                var sendCommand = new AutoUploadSwitchStatusCommand(deviceNumber, itemCount, switchNumber);
                var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <SwitchItem>(this, sendCommand, null, queryTime);
                var task = tlAutoDeviceSerialPortAsync.InvokeAsync();
                tasks.Add(task);
            });
            var switchItems = await Task.WhenAll(tasks.ToArray());

            return(switchItems);
        }