/// <summary> /// request to receive the current status of all Servos. the StatusReceived event will fire after this call for each servo /// </summary> public async Task <ServoStatusResponse[]> GetStatusAsync() { var result = new ServoStatusResponse[Count]; return(await _runner.ExecuteAsync(new AsyncCommand <ServoStatusResponse[]>(new ServoStatusCommand(), i => { var response = i as ServoStatusResponse; if (response != null) { //record response for servo result[response.ServoID - 1] = response; //return when all received if (!result.Any(e => e == null)) { return result; } } return null; }))); }
void StatusResponse(ServoStatusResponse status) { //fire the event for the correct servo GetServo(status.ServoID)?.StatusResponse(status); }
internal void StatusResponse(ServoStatusResponse status) { //fire the event StatusReceived?.Invoke(_arm, new DataEventArg <ServoStatusResponse>(status)); }