public async Task <IEnumerable <RelayItem> > QueryRelayStatus(int deviceNumber, int itemCount)
        {
            var sendCommand = new QueryCustom4RelayStatusCommand(deviceNumber, itemCount);
            var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <IEnumerable <RelayItem> >(TLAutoDeviceSerialPort, sendCommand, null);

            return(await tlAutoDeviceSerialPortAsync.InvokeAsync());
        }
        public async Task <bool> PowerOff()
        {
            var sendCommand       = new PowerOffCommand();
            var tlSerialPortAsync = new TLAutoDeviceSerialPortAsync <bool>(TLAutoDeviceSerialPort, sendCommand, null, _logModuleName, _timeOutMs);

            return(await tlSerialPortAsync.InvokeAsync());
        }
        public virtual async Task <bool> ChangeDeviceNumber(int deviceNumber)
        {
            var sendCommand = new ChangeDeviceNumberCommand(deviceNumber);
            var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <bool>(TLAutoDeviceSerialPort, sendCommand, null, _logModuleName, _timeOutMs);

            return(await tlAutoDeviceSerialPortAsync.InvokeAsync());
        }
示例#4
0
        public override async Task <IEnumerable <SwitchItem> > QueryDigitalSwitchStatus(int deviceNumber, int itemCount)
        {
            var sendCommand = new QueryCustom1SwitchStatusCommand(deviceNumber, itemCount);
            var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <IEnumerable <SwitchItem> >(TLAutoDeviceSerialPort, sendCommand, null, _logModuleName, _timeOutMs);

            return(await tlAutoDeviceSerialPortAsync.InvokeAsync());
        }
        public async Task <bool> ChangeDeviceNumber(int deviceNumber)
        {
            var sendCommand = new ChangeDeviceNumberCommand(deviceNumber);
            var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <bool>(this, sendCommand, null, 5000);

            return(await tlAutoDeviceSerialPortAsync.InvokeAsync());
        }
示例#6
0
        public async Task <IEnumerable <SwitchItem> > QuerySwitchStatus(int deviceNumber, int itemCount)
        {
            var sendCommand = new QuerySwitchStatusCommand(deviceNumber, itemCount);
            var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <IEnumerable <SwitchItem> >(this, sendCommand, null, 5000);

            return(await tlAutoDeviceSerialPortAsync.InvokeAsync());
        }
        public async Task <bool> ControlRelay(int deviceNumber, int itemCount, int relayNumber, RelayStatus relayStatus)
        {
            var sendCommand = new ControlRelayStatusCustom4Command(deviceNumber, relayNumber, relayStatus, itemCount);
            var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <bool>(TLAutoDeviceSerialPort, sendCommand, null);
            await tlAutoDeviceSerialPortAsync.InvokeAsync();

            return(true);
        }
        public virtual async Task <bool> ControlRelay(int deviceNumber, int itemCount, int relayNumber, RelayStatus relayStatus)
        {
            var sendCommand = new ControlRelayStatusCommand(deviceNumber, relayNumber, relayStatus, itemCount, _hasControlRelayResultStatus);
            var tlAutoDeviceSerialPortAsync = new TLAutoDeviceSerialPortAsync <bool>(TLAutoDeviceSerialPort, sendCommand, null);
            var result = await tlAutoDeviceSerialPortAsync.InvokeAsync();

            if (_hasControlRelayResultStatus)
            {
                return(result);
            }
            return(true);
        }
示例#9
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);
        }