public bool startService()
        {
            if (this.StartedService)
            {
                return(false);
            }

            mMechanicalConn = new SerialPortInput();
            mCodec          = new MotionCodec();
            mMechanicalConn.SetPort(mConnPort, mBaudrate);
            mMechanicalService = new MechanicalService(mMechanicalConn, mCodec);
            mMechanicalService.passingMessageEvent += new PassingMessageHandler(handleResponseMessage);
            if (!mMechanicalService.startService())
            {
                this.StartedService = false;
                return(false);
            }

            this.StartedService = true;
            this.ReadyMotion    = false;
            this.mReadyFlag     = true;
            this.enableMotion();
//            this.controlHomeMotion();
            if (this.mTimerCheckReady == null)
            {
                this.mTimerCheckReady = new DispatcherTimer();
            }
            this.mTimerCheckReady.Interval = TimeSpan.FromSeconds(1);
            this.mTimerCheckReady.Tick    += this.onTimerTick;
            this.mTimerCheckReady.Start();
            return(true);
        }
示例#2
0
        public bool startService()
        {
            if (this.StartedService)
            {
                return(false);
            }

            mConn  = new UDPConnector();
            mCodec = new KLVCodec();
            mConn.Configure(mSendPort, mSendIP, mReceivePort, mReceiveIP);
            mDetectorService = new DetectorService(mConn, mCodec);

            mDetectorService.passingMessageEvent += new PassingMessageHandler(handleResponseMessage);
            if (!mDetectorService.startService())
            {
                this.StartedService = false;
                return(false);
            }

            this.StartedService = true;
            return(true);
        }
示例#3
0
        public ServiceAbstract(ConnectorAbstract con, CodecAbstract codec)
        {
            mConnector = con;
            mCodec     = codec;

            mConnector.ConnectionStatusChanged += delegate(object sender, ConnectionStatusChangedEventArgs arg)
            {
                Logger.Info("Connected = {0}", arg.Connected);
            };

            mConnector.MessageReceived += delegate(object sender, MessageReceivedEventArgs arg)
            {
                List <BaseMessage> listMsg = mCodec.decode(arg.Data);
                foreach (BaseMessage msg in listMsg)
                {
                    if (msg != null)
                    {
                        processIoMessage(msg);
                    }
                }
            };
        }
示例#4
0
 public MechanicalService(ConnectorAbstract con, CodecAbstract codec) : base(con, codec)
 {
 }
示例#5
0
 public DetectorService(ConnectorAbstract con, CodecAbstract codec) : base(con, codec)
 {
 }