예제 #1
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();
        }