예제 #1
0
        public async Task <string> Connect(string exePath = null)
        {
            try
            {
                string       address = null;
                ProcessUtils proc    = new ProcessUtils(c_processName, exePath);
                if (!proc.IsRunning())
                {
                    await proc.Start((msg) => ProcessStdOutCallBack(msg, ref address));

                    if (String.IsNullOrEmpty(address))
                    {
                        return(cFailed);
                    }
                }
                else
                {
                    address = cBasePipeAddress;
                }

                if (!String.IsNullOrEmpty(address))
                {
                    _channel = CreateChannel(address);

                    // call a function to test consistency of contract file.
                    string test = _channel.GetCameraJson();

                    if (_channel != null)
                    {
                        return(cSuccess);
                    }
                    else
                    {
                        return(cFailed);
                    }
                }
                return(cFailed);
            }
            catch
            {
                _channel = null;
                return(cFailed);
            }
        }
예제 #2
0
        public string GetCamera()
        {
            if (_channel == null)
            {
                return(cNeedConnect);
            }

            try
            {
                return(_channel.GetCameraJson());
            }
            catch (Exception ex)
            {
                if (ex is FaultException <EarthNamedpipeFault> )
                {
                    return((ex as FaultException <EarthNamedpipeFault>).Message);
                }
                else
                {
                    return(ex.Message);
                }
            }
        }
예제 #3
0
        public bool Connect()
        {
            try
            {
                _channel = CreateChannel(cBasePipeAddress);
                // call a function to test consistency of contract file.
                string test = _channel.GetCameraJson();

                if (_channel != null)
                {
                    return(true);
                }
                else
                {
                    _channel = null;
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }