private void UpdateGui(SessionRecord sessionRecord) { using (var context = new HelicopterModelEntities()) { var yaw = sessionRecord.ControllerRecords.Single(x => x.MotorType == MotorType.Yaw.ToString()); var tilt = sessionRecord.ControllerRecords.Single(x => x.MotorType == MotorType.Tilt.ToString()); SessionStartTimeTextBlock.Text = sessionRecord.StartTime.ToString(); SessionEndTimeTextBlock.Text = sessionRecord.EndTime.ToString(); YawCWPGainTextBlock.Text = yaw.CWProportionalGain.ToString(); YawCWIGainTextBlock.Text = yaw.CWIntegralGain.ToString(); YawCWDGainTextBlock.Text = yaw.CWDerivativeGain.ToString(); YawCCWPGainTextBlock.Text = yaw.CCWProportionalGain.ToString(); YawCCWIGainTextBlock.Text = yaw.CCWIntegralGain.ToString(); YawCCWDGainTextBlock.Text = yaw.CCWDerivativeGain.ToString(); YawWindupTextBlock.Text = yaw.IntegralWindupThreshold.ToString(); YawOutputRateLimitTextBlock.Text = yaw.OutputRateLimit.ToString(); YawDriverType.Text = yaw.DriverType; TiltPGainTextBlock.Text = tilt.CWProportionalGain.ToString(); TiltIGainTextBlock.Text = tilt.CWIntegralGain.ToString(); TiltDGainTextBlock.Text = tilt.CWDerivativeGain.ToString(); TiltWindupTextBlock.Text = yaw.IntegralWindupThreshold.ToString(); TiltOutputRateLimitTextBlock.Text = tilt.OutputRateLimit.ToString(); TiltDriverType.Text = tilt.DriverType; SessionComment.Text = sessionRecord.Comment; } }
public SessionPidChartWindow(SessionRecord sessionRecord) { this.sessionRecord = sessionRecord; InitializeComponent(); UpdateGui(sessionRecord); StaticPidChart.LoadNewData(sessionRecord); SessionComment.Focus(); SessionComment.CaretIndex = SessionComment.Text.Length; }
public void LoadNewData(SessionRecord sessionRecord) { var yaw = sessionRecord.ControllerRecords.Single(x => x.MotorType == MotorType.Yaw.ToString()); var tilt = sessionRecord.ControllerRecords.Single(x => x.MotorType == MotorType.Tilt.ToString()); var yawTimes = yaw.MeasurementRecords.Select(x => (x.TimeStamp - sessionRecord.StartTime).TotalSeconds); var yawAngles = yaw.MeasurementRecords.Select(x => x.CurrentAngle); var yawSetPoints = yaw.MeasurementRecords.Select(x => x.SetPoint); var tiltTimes = tilt.MeasurementRecords.Select(x => (x.TimeStamp - sessionRecord.StartTime).TotalSeconds); var tiltAngles = tilt.MeasurementRecords.Select(x => x.CurrentAngle); var tiltSetPoints = tilt.MeasurementRecords.Select(x => x.SetPoint); this.yawAngles.Append(yawTimes, yawAngles); this.yawSetPoints.Append(yawTimes, yawSetPoints); this.tiltAngles.Append(tiltTimes, tiltAngles); this.tiltSetPoints.Append(tiltTimes, tiltSetPoints); YawAngleSeries.DataSeries = this.yawAngles; YawSetPointSeries.DataSeries = this.yawSetPoints; TiltAngleSeries.DataSeries = this.tiltAngles; TiltSetPointSeries.DataSeries = this.tiltSetPoints; }
public static SessionRecord CreateNewSessionRecord(Session session, HelicopterSettings settings) { SessionRecord sessionRecord; var yaw = session.YawDataSeries; var tilt = session.TiltDataSeries; using (var context = new HelicopterModelEntities()) { var settingsRecordId = UpdateSettingsRecord(settings, context); sessionRecord = new SessionRecord { SettingsId = settingsRecordId, StartTime = session.StartTime, EndTime = session.EndTime, Comment = String.Empty }; var yawRecord = new ControllerRecord { MotorType = yaw.MotorType.ToString(), DriverType = yaw.MotorDriver.ToString(), CWProportionalGain = yaw.CWProportionalGain, CWIntegralGain = yaw.CWIntegralGain, CWDerivativeGain = yaw.CWDerivativeGain, CCWProportionalGain = yaw.CCWProportionalGain, CCWIntegralGain = yaw.CCWIntegralGain, CCWDerivativeGain = yaw.CCWDerivativeGain, IntegralWindupThreshold = yaw.IWindupThreshold, OutputRateLimit = yaw.OutputRateLimit, MeasurementRecords = yaw.ControllerData.Select(x => new MeasurementRecord { TimeStamp = x.TimeStamp, SetPoint = x.SetPoint, CurrentAngle = x.CurrentAngle }).ToList() }; var tiltRecord = new ControllerRecord { MotorType = tilt.MotorType.ToString(), DriverType = tilt.MotorDriver.ToString(), CWProportionalGain = tilt.CWProportionalGain, CWIntegralGain = tilt.CWIntegralGain, CWDerivativeGain = tilt.CWDerivativeGain, IntegralWindupThreshold = tilt.IWindupThreshold, OutputRateLimit = tilt.OutputRateLimit, MeasurementRecords = tilt.ControllerData.Select(x => new MeasurementRecord { TimeStamp = x.TimeStamp, SetPoint = x.SetPoint, CurrentAngle = x.CurrentAngle }).ToList() }; sessionRecord.ControllerRecords.Add(yawRecord); sessionRecord.ControllerRecords.Add(tiltRecord); context.SessionRecords.Add(sessionRecord); context.SaveChanges(); Log.Debug("Created and saved new session with ID"); } return sessionRecord; }