Пример #1
0
        public static async Task <bool> InvokerQueryDiaitalSwitchWithAutoUpload(MachineButtonItem boardItem, int queryTime)
        {
            var boardSendCommand = new NetTcpWcfClientService <ITLAutoDevice>(boardItem.ServiceAddress, TimeSpan.FromMilliseconds(queryTime));
            var result           = await boardSendCommand.SendAsync(async proxy =>
            {
                var controlInfo = new ControlInfo {
                    ServiceKey = CommonConfigHelper.PLCServiceKey
                };
                var serviceData = new PLCControlServiceData
                {
                    ControlPLCType         = ControlPLCType.QueryDiaitalSwitchWithAutoUpload,
                    DeviceNumber           = boardItem.DeviceNumber,
                    Number                 = new[] { boardItem.Number },
                    PortSignName           = boardItem.SignName,
                    QueryTimeForAutoUpload = queryTime
                };
                controlInfo.Data = serviceData.ToBytes();
                var resultInfo   = await proxy.ControlDevice(controlInfo);
                if (!resultInfo.IsError && (resultInfo.Data != null))
                {
                    var switchItems = resultInfo.Data.ToObject <IEnumerable <SwitchItem> >().ToList();
                    var switchItem  = switchItems.Find(s => (s != null) && (s.SwitchNumber == boardItem.Number) && s.SwitchStatus.ToInt32().ToBoolean());
                    if (switchItem != null)
                    {
                        return(true);
                    }
                }
                return(false);
            });

            return(result);
        }
Пример #2
0
        public static async Task <bool> InvokerControlRelay(MachineRelayItem relayItem, bool isNo)
        {
            var notificationService = new NetTcpWcfClientService <ITLAutoDevice>(relayItem.ServiceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy =>
            {
                var controlInfo = new ControlInfo {
                    ServiceKey = CommonConfigHelper.PLCServiceKey
                };
                var serviceData = new PLCControlServiceData
                {
                    ControlPLCType = ControlPLCType.ControlRelay,
                    DeviceNumber   = relayItem.DeviceNumber,
                    Number         = new[] { relayItem.Number },
                    PortSignName   = relayItem.SignName,
                    RelayStatus    = isNo
                };
                controlInfo.Data = serviceData.ToBytes();
                var resultInfo   = await proxy.ControlDevice(controlInfo);
                if (!resultInfo.IsError && (resultInfo.Data != null))
                {
                    return(true);
                }
                return(false);
            });

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #3
0
        public static async Task <bool> InvokerSimulationDigitalSwitch(SwitchItem boardItem)
        {
            var sendWcfCommand = new NetTcpWcfClientService <ITLAutoDevice>(boardItem.ServiceAddress);
            var result         = await sendWcfCommand.SendAsync(async proxy =>
            {
                var controlInfo = new ControlInfo {
                    ServiceKey = CommonConfigHelper.PLCServiceKey
                };
                var serviceData = new PLCControlServiceData
                {
                    ControlPLCType = ControlPLCType.SimulationDigitalSwitch,
                    DeviceNumber   = boardItem.DeviceNumber,
                    Number         = new[] { boardItem.Number },
                    PortSignName   = boardItem.SignName
                };
                controlInfo.Data = serviceData.ToBytes();
                var resultInfo   = await proxy.ControlDevice(controlInfo);
                if (!resultInfo.IsError && (resultInfo.Data != null))
                {
                    var result1 = resultInfo.Data[0].ToBoolean();
                    return(result1);
                }
                return(false);
            });

            return(result);
        }
Пример #4
0
        public static async Task <bool> InvokerTextToMusic(string text, string serviceAddress, int volume = 100)
        {
            var notificationService = new NetTcpWcfClientService <ITLMusic>(serviceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.SpeakFromText(text, volume));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #5
0
        //public static async Task<bool> InvokerPlayVideo(string videoKey, string videoPath, string startArgs, string serviceAddress)
        //{
        //    var notificationService = new NetTcpWcfClientService<ITLNotification>(serviceAddress);
        //    RegWcfEvents(notificationService);
        //    var result = await notificationService.SendAsync(async proxy => await proxy.StartApp(videoKey, videoPath, startArgs, new List<BoardNotificationInfo>(), new List<BoardNotificationInfo>(), new List<string>()));
        //    UnregWcfEvents(notificationService);
        //    return result;
        //}

        //public static async Task<bool> InvokerStopVideo(string serviceAddress)
        //{
        //    var notificationService = new NetTcpWcfClientService<ITLNotification>(serviceAddress);
        //    RegWcfEvents(notificationService);
        //    var result = await notificationService.SendAsync(async proxy => await proxy.StopApp("TLAuto.Video.App"));
        //    UnregWcfEvents(notificationService);
        //    return result;
        //}

        public static async Task <bool> InvokerMusic(string musicKey, string filePath, double volume, bool isRepeat, string serviceAddress)
        {
            var notificationService = new NetTcpWcfClientService <ITLMusic>(serviceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.PlayMusic(musicKey, filePath, volume, isRepeat));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #6
0
        public static async Task <bool> ChangeFrame(TimeSpan time, VideoActionType afterVideoActionType, string serviceAddress)
        {
            var notificationService = new NetTcpWcfClientService <ITLVideo>(serviceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.ChangeFrame(time, afterVideoActionType));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #7
0
        public static async Task <bool> SetPauseTimeEvent(TimeSpan time, string serviceAddress)
        {
            var notificationService = new NetTcpWcfClientService <ITLVideo>(serviceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.SetPauseTimeEvent(time));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #8
0
        public static async Task <bool> InvokerAction(VideoActionType videoActionType, string serviceAddress)
        {
            var notificationService = new NetTcpWcfClientService <ITLVideo>(serviceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.InvokerAction(videoActionType));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #9
0
        public static async Task <AppStatusType> GetNotificationStatus(string notificationKey, string serviceAddress = null)
        {
            var notificationService = new NetTcpWcfClientService <ITLNotification>(serviceAddress ?? CommonConfigHelper.NotificationServiceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.GetAppStatus(notificationKey));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #10
0
        public static async Task <bool> InvokerNotificationForStop(string notificationKey)
        {
            var notificationService = new NetTcpWcfClientService <ITLNotification>(CommonConfigHelper.NotificationServiceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.AddAppStatus(notificationKey, AppStatusType.Stop));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #11
0
        public static async Task <bool> PlayVideo(string key, string fileName, double volume, bool isRepeat, string serviceAddress)
        {
            var filePathBase        = @"C:\Program Files\StartGateServer\TLAuto.Machine\" + key + @"\MachinePlugins\Video";
            var notificationService = new NetTcpWcfClientService <ITLVideo>(serviceAddress);

            RegWcfEvents(notificationService);
            var result = await notificationService.SendAsync(async proxy => await proxy.PlayVideo(Path.Combine(filePathBase, fileName), volume, isRepeat));

            UnregWcfEvents(notificationService);
            return(result);
        }
Пример #12
0
        private async Task <T> SendCommand <T>(Func <ITLNotification, Task <T> > func)
        {
            if (!IsOpen)
            {
                MessageBox.Show("通讯服务未启动。");
                return(default(T));
            }
            NotificationVm.IsSendCommand = true;
            var notificationSendCommand = new NetTcpWcfClientService <ITLNotification>(ConfigHelper.ServiceAddress);

            notificationSendCommand.Error += (s, e) => { WriteMsg(e.Msg); };
            notificationSendCommand.CommunicationError += (s, e) => { WriteMsg(e.Msg); };
            notificationSendCommand.TimeoutError       += (s, e) => { WriteMsg(e.Msg); };
            var result = await notificationSendCommand.SendAsync(func);

            NotificationVm.IsSendCommand = false;
            return(result);
        }
Пример #13
0
        public static async Task <bool> InvokerPauseMusic(string musicKey, string serviceAddress)
        {
            var notificationService = new NetTcpWcfClientService <ITLMusic>(serviceAddress);

            return(await notificationService.SendAsync(async proxy => await proxy.PauseMusic(musicKey)));
        }
Пример #14
0
        public async Task <bool> Connected()
        {
            var notificationSendCommand = new NetTcpWcfClientService <ITLNotification>(ConfigHelper.ServiceAddress);

            return(await notificationSendCommand.SendAsync(async proxy => await proxy.TestConnected()));
        }