Esempio n. 1
0
 }

        async Task ConnectDongle()
        {
            var ipAddress = ServiceTool.Network.Helper.GetIPAddress();
            if (ipAddress.Contains("10.10.10"))
            {
                PortSwitch = new PortSwitch();
                await PortSwitch.ConnectDongle();
                PortSwitch.OnPortStatus += (sender, e) => PortStatus(e);
                PortSwitch.OnPortswapError += (sender, e) => PortSwitchStatus(e);

                PortSwitch.SrdoLocal.OnReadRsp += (sender, e) => Process(e);
                PortSwitch.SrdoLocal.OnWriteRsp += (sender, e) => Process(e);
                PortSwitch.SrdoLocal.OnReadParaRsp += (sender, e) => Process(e);
                PortSwitch.SrdoLocal.OnWriteParaRsp += (sender, e) => Process(e);
                PortSwitch.SrdoLocal.OnCommandRsp += (sender, e) => Process(e);
                PortSwitch.SrdoLocal.OnRTDRsp += (sender, e) => Process(e);
                PortSwitch.SrdoLocal.OnRTDStopRsp += (sender, e) => Process(e);

                PortSwitch.OnDongleDisconnet += (sender, e) => Disconnect();
            }
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
            // Release any cached data, images, etc that aren't in use.
        }

        public async void SendMessageAsync(object sender, EventArgs e)
        {
            if (PortSwitch != null)
            {
                //StatusTextView.Text = " ";

                await ReadSrdo();
                await WriteSrdo();
                await Task.Delay(200);
                await Command();
                //await Task.Delay(200);
                //await RTD();
                await Task.Delay(200);
                await WriteSrdoPara();
                await Task.Delay(200);
                await ReadSrdoPara();
                await Task.Delay(200);
                //await PortSwitch.SwapBackToSVT();
                await ReadAllSRDOS();
                await PortSwitch.Resend();
            }
            else
            {
                var okAlertController = UIAlertController.Create("Error", "Not Connected!", UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(okAlertController, true, null);
            }
        }
Esempio n. 2
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            SetupPicker();
            ResponseText.Text = strSRDOResp;


            // Perform any additional setup after loading the view, typically from a nib.
            //Dongle
            var ipAddress = ServiceTool.Network.Helper.GetIPAddress();
            if (ipAddress.Contains("10.10.10"))
            {
                PortSwitch = new PortSwitch();
                await PortSwitch.ConnectDongle();
                PortSwitch.OnPortStatus += (sender, e) => PortStatus(e);
                PortSwitch.OnPortswapError += (sender, e) => PortSwitchStatus(e);

                PortSwitch.SrdoLocal.OnReadRsp += (sender, e) => Process(e);
                PortSwitch.SrdoLocal.OnWriteRsp += (sender, e) =>  Process(e);
                PortSwitch.SrdoLocal.OnReadParaRsp += (sender, e) =>  Process(e);
                PortSwitch.SrdoLocal.OnWriteParaRsp += (sender, e) =>  Process(e);
                PortSwitch.SrdoLocal.OnCommandRsp += (sender, e) =>  Process(e);
                PortSwitch.SrdoLocal.OnRTDRsp += (sender, e) =>  Process(e);
                PortSwitch.SrdoLocal.OnRTDStopRsp += (sender, e) =>  Process(e);

                PortSwitch.OnDongleDisconnet += (sender, e) => Disconnect();
                PortSwitch.OnPortZkip += (sender, e) => ZkipStatus(e);
            }
            else
            {
                var okAlertController = UIAlertController.Create("Connection Issue", "Please connect SVT dongle...", UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(okAlertController, true, null);
            }

            //SaveBtn.TouchUpInside += SaveResponse;
            this.NavigationItem.SetRightBarButtonItem(
            new UIBarButtonItem(
                    UIBarButtonSystemItem.Done,
                    SendMessageAsync)
            , true);


            // Change the host name here to change the server you want to monitor.
            //const string remoteHostName = "10.10.10.1";
            System.Net.IPAddress ipAdd = System.Net.IPAddress.Parse("10.10.10.1");
           
            hostReachability = Reachability.ReachabilityWithAddress(ipAdd);
            hostReachability.StartNotifier();
        }