/// <summary> /// Replace Handler sets Dashboard State /// </summary> /// <param name="replace"></param> IEnumerator<ITask> ReplaceHandler(Replace replace) { _state = replace.Body; replace.ResponsePort.Post(dssp.DefaultReplaceResponseType.Instance); yield break; }
/// <summary> /// Entry Point for the Dashboard Service /// </summary> protected override void Start() { // TT - Added code to create a default State if no // config file exists if (_state == null) { _state = new StateType(); _state.Log = false; _state.LogFile = ""; _state.Machine = ""; _state.Port = 0; } // TT - Version 2 - The options "bag" // This is tacky, but we need to set the default values // in case there is no existing config.xml file if (_state.Options == null) { _state.Options = new GUIOptions(); _state.Options.DeadZoneX = 80; _state.Options.DeadZoneY = 80; _state.Options.TranslateScaleFactor = 1.0; _state.Options.RotateScaleFactor = 0.5; _state.Options.ShowLRF = false; _state.Options.ShowArm = false; _state.Options.DisplayMap = false; // Updated in later versions with more options // These values are in mm _state.Options.RobotWidth = 300; _state.Options.MaxLRFRange = 8192; _state.Options.DriveDistance = 300; // Speed is in mm/sec??? _state.Options.MotionSpeed = 100; // Angle is in degrees _state.Options.RotateAngle = 45; // Camera update interval in milliseconds // Note that this is only required for the // simulated webcam because it does not provide // updates when you subscribe _state.Options.CameraInterval = 250; } if (_state.Options.CameraInterval < 100) _state.Options.CameraInterval = 100; // Handlers that need write or exclusive access to state go under // the exclusive group. Handlers that need read or shared access, and can be // concurrent to other readers, go to the concurrent group. // Other internal ports can be included in interleave so you can coordinate // intermediate computation with top level handlers. Activate(Arbiter.Interleave( new TeardownReceiverGroup ( Arbiter.Receive<DsspDefaultDrop>(false, _mainPort, DropHandler) ), new ExclusiveReceiverGroup ( Arbiter.ReceiveWithIterator<Replace>(true, _mainPort, ReplaceHandler), Arbiter.ReceiveWithIterator<OnLoad>(true, _eventsPort, OnLoadHandler), Arbiter.Receive<OnClosed>(true, _eventsPort, OnClosedHandler), Arbiter.ReceiveWithIterator<OnChangeJoystick>(true, _eventsPort, OnChangeJoystickHandler), Arbiter.Receive<OnLogSetting>(true, _eventsPort, OnLogSettingHandler), // TT - Added this handler for Connection parameters Arbiter.Receive<OnConnectSetting>(true, _eventsPort, OnConnectSettingHandler), // TT - Added this handler for Options Arbiter.Receive<OnOptionSettings>(true, _eventsPort, OnOptionSettingsHandler), // TT - Added this handler for Webcam Arbiter.ReceiveWithIterator<OnConnectWebCam>(true, _eventsPort, OnConnectWebCamHandler), Arbiter.ReceiveWithIterator<cam.UpdateFrame>(true, _webCamNotify, CameraUpdateFrameHandler) ), new ConcurrentReceiverGroup ( Arbiter.Receive<DsspDefaultLookup>(true,_mainPort,DefaultLookupHandler), Arbiter.ReceiveWithIterator<Get>(true, _mainPort, GetHandler), // TT Dec-2006 - Updated for V1.0 Arbiter.ReceiveWithIterator<game.Replace>(true, _gameControllerNotify, JoystickReplaceHandler), Arbiter.ReceiveWithIterator<sicklrf.Replace>(true, _laserNotify, OnLaserReplaceHandler), Arbiter.ReceiveWithIterator<OnConnect>(true, _eventsPort, OnConnectHandler), Arbiter.ReceiveWithIterator<drive.Update>(true, _driveNotify, OnDriveUpdateNotificationHandler), Arbiter.ReceiveWithIterator<OnConnectMotor>(true, _eventsPort, OnConnectMotorHandler), Arbiter.ReceiveWithIterator<OnMove>(true, _eventsPort, OnMoveHandler), // TT May-2007 - Added Rotate and Translate Arbiter.ReceiveWithIterator<OnRotate>(true, _eventsPort, OnRotateHandler), Arbiter.ReceiveWithIterator<OnTranslate>(true, _eventsPort, OnTranslateHandler), Arbiter.ReceiveWithIterator<OnEStop>(true, _eventsPort, OnEStopHandler), Arbiter.ReceiveWithIterator<OnStartService>(true, _eventsPort, OnStartServiceHandler), Arbiter.ReceiveWithIterator<OnConnectSickLRF>(true, _eventsPort, OnConnectSickLRFHandler), Arbiter.Receive<OnDisconnectSickLRF>(true, _eventsPort, OnDisconnectSickLRFHandler), Arbiter.ReceiveWithIterator<OnConnectArticulatedArm>(true, _eventsPort, OnConnectArticulatedArmHandler), Arbiter.ReceiveWithIterator<OnApplyJointParameters>(true, _eventsPort, OnApplyJointParametersHandler) ) )); DirectoryInsert(); WinFormsServicePort.Post(new RunForm(CreateForm)); }