private void Runtime_Cancelled(object sender, string e) { if (_misty != null) { _misty.SendDebugMessage($"Runtime '{e}' was cancelled.", null); } }
private async Task <Credential> getAuthToken() { _misty.SendDebugMessage("Starting skill", null); HttpResponseMessage response = await _client.PostAsync("https://us-central1-mistyapi-pxxkne.cloudfunctions.net/authToken", null); string stringResponse = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <Credential>(stringResponse)); }
/// <summary> /// This event handler is called when the robot/user sends a start message /// The parameters can be set in the Skill Runner (or as json) and used in the skill if desired /// </summary> /// <param name="parameters"></param> public void OnStart(object sender, IDictionary <string, object> parameters) { try { _misty.SendDebugMessage("MistyMiner skill started", null); _misty.MoveHead(20, 0, 0, 0, AngularUnit.Position, null); //_takeImageTimer = new Timer(CheckForOreCallback, null, 0, 5000); _misty.RegisterCapTouchEvent(CheckForOreCallback, 1000, true, null, null, null); _misty.RegisterIMUEvent(setYaw, 5, true, null, null, null); List <ActuatorPositionValidation> HeadPositionValidation = new List <ActuatorPositionValidation>(); HeadPositionValidation.Add(new ActuatorPositionValidation { Name = ActuatorPositionFilter.SensorName, Comparison = ComparisonOperator.Equal, ComparisonValue = ActuatorPosition.HeadPitch }); _misty.RegisterActuatorEvent(setHeadPitch, 10, true, HeadPositionValidation, null, null); List <ActuatorPositionValidation> ArmPositionValidation = new List <ActuatorPositionValidation>(); ArmPositionValidation.Add(new ActuatorPositionValidation { Name = ActuatorPositionFilter.SensorName, Comparison = ComparisonOperator.Equal, ComparisonValue = ActuatorPosition.RightArm }); _misty.RegisterActuatorEvent(setArmPitch, 100, true, ArmPositionValidation, null, null); _misty.RegisterTimeOfFlightEvent(setTimeOfFlight, 0, true, null, null, null); //Clean up any lingering runs yaw.YawReached -= HandleYawReached; yaw.YawReached -= HandleReturnYawReached; yaw.YawReached -= FinalYaw; tof.DistanceReached -= HandleOreReached; tof.DistanceReached -= HandleReturnReached; arm.ArmPosReached -= ArmDown; arm.ArmPosReached -= ArmUp; } catch (Exception ex) { _misty.SkillLogger.Log($"MistyMiner : OnStart: => Exception", ex); _misty.SendDebugMessage($"MistyMiner : OnStart: => Exception" + ex, null); } }