private void btnSetMode_Click(object sender, EventArgs e) { Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Change Mode", new ChangeModeMessage((ChangeModeMessage.Mode)cmbMode.SelectedValue), true, false, device).run(); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { } }
private void btnGetVersion_Click(object sender, EventArgs e) { Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Get Version", new GetVersionMessage(), true, false, device).run(); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { GetVersionResponse resp = (GetVersionResponse)r.resultObj; log.Info(resp.ToString()); } }
private void btnSendControlMsg_Click(object sender, EventArgs e) { UInt16 identifier = Convert.ToUInt16(txtIdentifier.Text); txtIdentifier.Text = (identifier + 1).ToString(); Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Send Control Message", new ControlMessage(radTx.Checked, Convert.ToInt32(cmbPAGain.SelectedValue), (radAnt0.Checked ? ControlMessage.TxAntenna.ANT0 : ControlMessage.TxAntenna.ANT1), (radHigh.Checked ? ControlMessage.Frequency.HIGH : ControlMessage.Frequency.LOW), chkReset.Checked, identifier, chkDontUpdate.Checked), true, false, device).run(10000); if (r?.result == Scenario.ScenarioResult.RunResult.Pass) { GetRawStatusResponse resp = (GetRawStatusResponse)r.resultObj; StringBuilder sb = new StringBuilder(); sb.Append("TTI Counter: "); sb.AppendLine(resp.ttiCounter.ToString()); sb.Append("Identifier: "); sb.AppendLine(resp.Identifier.ToString()); sb.AppendLine("Forward Power: "); foreach (UInt16 f in resp.fwdPower) { sb.Append(f.ToString() + " "); } sb.AppendLine(""); sb.AppendLine("Input Power: "); foreach (UInt16 f in resp.inputPower) { sb.Append(f.ToString() + " "); } sb.AppendLine(""); sb.Append("Power Difference Status: "); if (resp.reversePowerStatus > 0) { sb.AppendLine("Pass "); } else { sb.AppendLine("Fail "); } sb.Append("Temperature: "); sb.AppendLine(resp.temperature.ToString()); sb.Append("Amplifier Current: "); sb.AppendLine(resp.powerAmplifierCurrent.ToString()); sb.Append("Pwr-Amp Gain: "); sb.AppendLine(resp.paGain.ToString()); sb.Append("Antenna: "); sb.AppendLine(resp.txAnt.ToString()); sb.Append("Frequncy: "); sb.AppendLine(resp.frequency.ToString()); txtStatus.Text = sb.ToString(); } }
private void setPowerCalibTable(DataGridView grid, CalibrationTable.TableType tableType) { PowerCalibrationTable tbl = new PowerCalibrationTable(); int i = 0; foreach (DataGridViewRow row in grid.Rows) { tbl.PA_GAIN_VALUES[i++] = Convert.ToUInt16(row.Cells["Value"].Value); } Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Set " + tableType.ToString() + " Calibration Data", new SetCalibrationTableMessage(tbl, tableType), true, false, device).run(); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { AckResponse resp = (AckResponse)r.resultObj; log.Info("got an ack response opcode: " + resp.opcode.ToString()); } }
private void btnSetGeneralCalib_Click(object sender, EventArgs e) { GeneralCalibrationTable tbl = new GeneralCalibrationTable(); foreach (DataGridViewRow row in gridGeneralCalib.Rows) { FieldInfo valueField = typeof(GeneralCalibrationTable).GetField(row.Cells["Key"].Value.ToString(), BindingFlags.Public | BindingFlags.Instance); valueField.SetValue(tbl, Convert.ToUInt16(row.Cells["Value"].Value)); } Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Set General Calibration Data", new SetCalibrationTableMessage(tbl, CalibrationTable.TableType.General), true, false, device).run(); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { AckResponse resp = (AckResponse)r.resultObj; log.Info("got an ack response opcode: " + resp.opcode.ToString()); } }
private void btnGetMomenteryStatus_Click(object sender, EventArgs e) { Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Get Momentery Status", new GetMomenteryStatusMessage(), true, false, device).run(); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { GetMomenteryStatusResponse resp = (GetMomenteryStatusResponse)r.resultObj; StringBuilder sb = new StringBuilder(); sb.Append("Pwr-Amp Gain: "); sb.AppendLine(resp.paGain.ToString()); sb.Append("Mode: "); sb.AppendLine(resp.mode.ToString()); sb.Append("Antenna: "); sb.AppendLine(resp.txAnt.ToString()); sb.Append("Frequncy: "); sb.AppendLine(resp.frequency.ToString()); //yehuda 22.5.18 add pre_amp to bit status sb.AppendLine("Pre-Amp Power: "); sb.Append(resp.preAmpPower1.ToString()); sb.Append(" "); sb.Append(resp.preAmpPower2.ToString()); sb.Append(" "); sb.Append(resp.preAmpPower3.ToString()); sb.Append(" "); sb.Append(resp.preAmpPower4.ToString()); sb.Append(" "); sb.AppendLine(""); sb.Append("Reverse Power: "); sb.Append(resp.reversePower1.ToString()); sb.Append(" "); sb.Append(resp.reversePower2.ToString()); sb.Append(" "); sb.Append(resp.reversePower3.ToString()); sb.Append(" "); sb.Append(resp.reversePower4.ToString()); sb.Append(" "); txtStatus.Text = sb.ToString(); } }
private void btnGetRawStatus_Click(object sender, EventArgs e) { Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Get Raw Status", new GetRawStatusMessage(), true, false, device).run(1300); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { GetRawStatusResponse resp = (GetRawStatusResponse)r.resultObj; StringBuilder sb = new StringBuilder(); sb.Append("TTI Counter: "); sb.AppendLine(resp.ttiCounter.ToString()); sb.Append("Identifier: "); sb.AppendLine(resp.Identifier.ToString()); sb.AppendLine("Forward Power: "); foreach (UInt16 f in resp.fwdPower) { sb.Append(f.ToString() + " "); } sb.AppendLine(""); sb.AppendLine("Input Power: "); foreach (UInt16 f in resp.inputPower) { sb.Append(f.ToString() + " "); } sb.AppendLine(""); sb.Append("Power Difference Status: "); if (resp.reversePowerStatus > 0) { sb.AppendLine("Pass "); } else { sb.AppendLine("Fail "); } txtStatus.Text = sb.ToString(); } }
private void getPowerCalibTable(DataGridView grid, CalibrationTable.TableType tableType) { Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Get " + tableType.ToString() + " Calibration Data", new GetCalibrationTableMessage(tableType), true, false, device).run(); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { GetCalibrationTableResponse resp = (GetCalibrationTableResponse)r.resultObj; PowerCalibrationTable tbl = (PowerCalibrationTable)resp.table; try { grid.Rows.Clear(); for (int i = 0; i < tbl.PA_GAIN_VALUES.Length; i++) { grid.Rows.Add(i.ToString(), tbl.PA_GAIN_VALUES[i]); } } catch (Exception ex) { log.Error("Could not load calibration data!", ex); } } }
private void btnGetGeneralCalibData_Click(object sender, EventArgs e) { Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Get General Calibration Data", new GetCalibrationTableMessage(CalibrationTable.TableType.General), true, false, device).run(); if (r != null && r.result == Scenario.ScenarioResult.RunResult.Pass) { GetCalibrationTableResponse resp = (GetCalibrationTableResponse)r.resultObj; GeneralCalibrationTable tbl = (GeneralCalibrationTable)resp.table; try { gridGeneralCalib.Rows.Clear(); FieldInfo[] fields = typeof(GeneralCalibrationTable).GetFields(); foreach (FieldInfo f in fields) { gridGeneralCalib.Rows.Add(f.Name, f.GetValue(tbl)); } } catch (Exception ex) { log.Error("Could not load calibration data!", ex); } } }
protected override ScenarioResult internalRun(CancellationToken ct) { try { /* start the conversion */ int blockCount = 0; int curBlock = 0; HexConverter h = new HexConverter(filePath); h.Process(); blockCount = h.lineCount(); progressFunc.Invoke(blockCount, 0, "Staring the " + operation.ToString() + " Operation..."); bool operationDone = false; while (!operationDone && !ct.IsCancellationRequested) { /* send a line*/ KeyValuePair <UInt32, byte[]> line; if (h.getNextLine(false, out line)) { if (operation == Operation.Program) { log.Info("Programming address: 0x" + line.Key.ToString("X")); Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Send Line Scenario", new SetBootDataMessage(line.Key, line.Value), true, false, device).run(); if (r == null || r.result != Scenario.ScenarioResult.RunResult.Pass) { throw new SoftwareUpdateException(); } SetBootDataResponse resp = (SetBootDataResponse)r.resultObj; if (resp.address != line.Key) { log.Error("set data at address: 0x" + line.Key.ToString("X") + " but got a response of: 0x" + resp.address.ToString("X")); throw new InvalidDataException(); } if (resp.status != SetBootDataResponse.Status.OK) { log.Error("set data err at address: 0x" + line.Key.ToString("X")); throw new InvalidDataException(); } } else if (operation == Operation.Verify) { log.Info("Verifying address: 0x" + line.Key.ToString("X")); Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Get Line Scenario", new GetBootDataMessage(line.Key), true, false, device).run(); if (r == null || r.result != Scenario.ScenarioResult.RunResult.Pass) { throw new SoftwareUpdateException(); } GetBootDataResponse resp = (GetBootDataResponse)r.resultObj; /* compare */ if (line.Key != resp.address) { log.Error("requested address: 0x" + line.Key.ToString("X") + " but got a response of: " + resp.address.ToString()); throw new InvalidDataException(); } if (line.Value.Length != resp.lineData.Length) { log.Error("somehow the secotr size is not equal in the hex and device!"); throw new InvalidDataException(); } for (int i = 0; i < line.Value.Length; i++) { if (line.Value[i] != resp.lineData[i]) { log.Error("verify failed at address: 0x" + (line.Key + i).ToString("X") + " - 0x" + resp.lineData[i].ToString("X") + " instead of: 0x" + line.Value[i].ToString("X")); throw new InvalidDataException(); } } } progressFunc.Invoke(blockCount, curBlock++, operation.ToString() + " operation in progress"); } else { Scenario.ScenarioResult r = new SingleMessageSingleDeviceScenario("Finish Update Scenario", new FinishUpdateMessage(), true, false, device).run(); if (r == null || r.result != Scenario.ScenarioResult.RunResult.Pass) { throw new SoftwareUpdateException(); } operationDone = true; } } if (ct.IsCancellationRequested) { progressFunc.Invoke(100, 0, operation.ToString() + " operation stopped"); } else { progressFunc.Invoke(100, 100, "Done."); } return(new ScenarioResult(ScenarioResult.RunResult.Pass, null)); } catch (Exception ex) { log.Error("error in \"Software Update Scenario\"", ex); progressFunc.Invoke(100, 0, "Error..."); return(new ScenarioResult(ScenarioResult.RunResult.Fail, null)); } finally { finishedFunc.Invoke(operation); } }