fix: 修复前端显示问题与后端无法读取Debugger数据的问题
This commit is contained in:
parent
82bc03b9fb
commit
2f1be8b0b7
|
@ -246,46 +246,6 @@ public class DebuggerController : ControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新开始触发(刷新后再启动触发器)
|
||||
/// </summary>
|
||||
[HttpPost("RestartTrigger")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public async Task<IActionResult> RestartTrigger()
|
||||
{
|
||||
try
|
||||
{
|
||||
var debugger = GetDebugger();
|
||||
if (debugger == null)
|
||||
return BadRequest("用户未绑定有效的实验板");
|
||||
|
||||
var refreshResult = await debugger.Refresh();
|
||||
if (!refreshResult.IsSuccessful)
|
||||
{
|
||||
logger.Error($"刷新调试器状态失败: {refreshResult.Error}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "刷新调试器状态失败");
|
||||
}
|
||||
|
||||
var startResult = await debugger.StartTrigger();
|
||||
if (!startResult.IsSuccessful)
|
||||
{
|
||||
logger.Error($"启动触发器失败: {startResult.Error}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "启动触发器失败");
|
||||
}
|
||||
|
||||
return Ok(startResult.Value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "重新开始触发时发生异常");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "操作失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取触发器状态标志
|
||||
/// </summary>
|
||||
|
@ -412,7 +372,15 @@ public class DebuggerController : ControllerBase
|
|||
return StatusCode(StatusCodes.Status500InternalServerError, "读取捕获数据失败");
|
||||
}
|
||||
|
||||
var freshResult = await debugger.Refresh();
|
||||
if (!freshResult.IsSuccessful)
|
||||
{
|
||||
logger.Error($"刷新调试器状态失败: {freshResult.Error}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "刷新调试器状态失败");
|
||||
}
|
||||
|
||||
var rawData = dataResult.Value;
|
||||
logger.Debug($"rawData: {BitConverter.ToString(rawData)}");
|
||||
int depth = (int)config.captureDepth;
|
||||
int portDataLen = 4 * depth;
|
||||
int portNum = (int)config.totalPortNum;
|
||||
|
@ -442,6 +410,7 @@ public class DebuggerController : ControllerBase
|
|||
UInt32 mask = (wireWidth == 32) ? 0xFFFFFFFF : ((1u << wireWidth) - 1u);
|
||||
channelUintArr[i] = (sample >> wireStart) & mask;
|
||||
}
|
||||
logger.Debug($"{channel.name} HexData: {BitConverter.ToString(channelUintArr.SelectMany(BitConverter.GetBytes).ToArray())}");
|
||||
var base64 = Convert.ToBase64String(channelUintArr.SelectMany(BitConverter.GetBytes).ToArray());
|
||||
channelDataList.Add(new ChannelCaptureData { name = channel.name, data = base64 });
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class DebuggerClient
|
|||
{
|
||||
var captureData = new byte[1024 * 4 * portNum];
|
||||
{
|
||||
var ret = await UDPClientPool.ReadAddr4BytesAsync(this.ep, this.taskID, this.captureDataAddr, captureData.Length, this.timeout);
|
||||
var ret = await UDPClientPool.ReadAddr4Bytes(this.ep, this.taskID, this.captureDataAddr, captureData.Length / 4, this.timeout);
|
||||
if (!ret.IsSuccessful)
|
||||
{
|
||||
logger.Error($"Failed to read data: {ret.Error}");
|
||||
|
|
|
@ -10,7 +10,12 @@
|
|||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click="startCapture(true)"
|
||||
@click="
|
||||
() => {
|
||||
handleDeleteData();
|
||||
startCapture();
|
||||
}
|
||||
"
|
||||
:disabled="!captureData"
|
||||
>
|
||||
重新捕获
|
||||
|
@ -137,7 +142,7 @@
|
|||
<span>显示</span>
|
||||
<span>颜色</span>
|
||||
<span>触发模式</span>
|
||||
<span>数据位宽(起始:宽度)</span>
|
||||
<span>数据位宽(起始:结尾)</span>
|
||||
<span>父端口编号</span>
|
||||
<span>操作</span>
|
||||
</div>
|
||||
|
@ -177,7 +182,7 @@
|
|||
<input
|
||||
v-model="ch.widthStr"
|
||||
class="input input-bordered w-full"
|
||||
placeholder="如0:8"
|
||||
placeholder="如0:7"
|
||||
@change="parseWidthStr(idx)"
|
||||
/>
|
||||
<input
|
||||
|
@ -280,7 +285,7 @@ interface DebugChannel {
|
|||
color: string;
|
||||
trigger: CaptureMode;
|
||||
width: number;
|
||||
widthStr: string; // "start:宽度"
|
||||
widthStr: string;
|
||||
start: number;
|
||||
parentPort: number;
|
||||
}
|
||||
|
@ -355,7 +360,7 @@ function addChannel() {
|
|||
color: "#00bcd4",
|
||||
trigger: CaptureMode.None,
|
||||
width: 1,
|
||||
widthStr: "0:1",
|
||||
widthStr: "0:0",
|
||||
start: 0,
|
||||
parentPort: 0,
|
||||
});
|
||||
|
@ -377,7 +382,7 @@ function stopCapture() {
|
|||
}
|
||||
}
|
||||
|
||||
async function startCapture(isRestart = false) {
|
||||
async function startCapture() {
|
||||
if (!configInited.value) {
|
||||
alert.error("请先配置调试器基本参数");
|
||||
return;
|
||||
|
@ -386,34 +391,33 @@ async function startCapture(isRestart = false) {
|
|||
alert.error("请至少添加一个通道");
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验通道参数
|
||||
if (!isRestart) {
|
||||
let usedWires = 0;
|
||||
for (let i = 0; i < channels.value.length; i++) {
|
||||
const ch = channels.value[i];
|
||||
if (!ch.visible) continue;
|
||||
if (!ch.name) {
|
||||
alert.error(`通道 ${i + 1} 名称不能为空`);
|
||||
return;
|
||||
}
|
||||
if (ch.width < 1 || ch.width > 32) {
|
||||
alert.error(`通道 ${i + 1} 数据位宽必须在1到32之间`);
|
||||
return;
|
||||
}
|
||||
if (ch.start < 0 || ch.start + ch.width > 32) {
|
||||
alert.error(`通道 ${i + 1} 起始位+宽度不能超过32`);
|
||||
return;
|
||||
}
|
||||
if (ch.parentPort < 0 || ch.parentPort >= config.totalPortNum) {
|
||||
alert.error(`通道 ${i + 1} 父端口编号超出范围`);
|
||||
return;
|
||||
}
|
||||
usedWires += ch.width;
|
||||
}
|
||||
if (usedWires > config.totalPortNum * 32) {
|
||||
alert.error("所有通道线宽总和不能超过最大线宽数");
|
||||
let usedWires = 0;
|
||||
for (let i = 0; i < channels.value.length; i++) {
|
||||
const ch = channels.value[i];
|
||||
if (!ch.visible) continue;
|
||||
if (!ch.name) {
|
||||
alert.error(`通道 ${i + 1} 名称不能为空`);
|
||||
return;
|
||||
}
|
||||
if (ch.width < 1 || ch.width > 32) {
|
||||
alert.error(`通道 ${i + 1} 数据位宽必须在1到32之间`);
|
||||
return;
|
||||
}
|
||||
if (ch.start < 0 || ch.start + ch.width > 32) {
|
||||
alert.error(`通道 ${i + 1} 起始位+宽度不能超过32`);
|
||||
return;
|
||||
}
|
||||
if (ch.parentPort < 0 || ch.parentPort >= config.totalPortNum) {
|
||||
alert.error(`通道 ${i + 1} 父端口编号超出范围`);
|
||||
return;
|
||||
}
|
||||
usedWires += ch.width;
|
||||
}
|
||||
if (usedWires > config.totalPortNum * 32) {
|
||||
alert.error("所有通道线宽总和不能超过最大线宽数");
|
||||
return;
|
||||
}
|
||||
|
||||
isCapturing.value = true;
|
||||
|
@ -444,28 +448,19 @@ async function startCapture(isRestart = false) {
|
|||
|
||||
try {
|
||||
// 设置通道模式
|
||||
if (!isRestart) {
|
||||
let ret = await client.setChannelsMode(apiConfig);
|
||||
if (!ret) {
|
||||
alert.error("设置通道模式失败");
|
||||
isCapturing.value = false;
|
||||
return;
|
||||
}
|
||||
let ret = await client.setChannelsMode(apiConfig);
|
||||
if (!ret) {
|
||||
alert.error("设置通道模式失败");
|
||||
isCapturing.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 启动捕获
|
||||
ret = await client.startTrigger();
|
||||
if (!ret) {
|
||||
alert.error("开始捕获失败,请检查连接");
|
||||
isCapturing.value = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
let ret = await client.restartTrigger();
|
||||
if (!ret) {
|
||||
alert.error("重新开始捕获失败,请检查连接");
|
||||
isCapturing.value = false;
|
||||
return;
|
||||
}
|
||||
// 启动捕获
|
||||
ret = await client.startTrigger();
|
||||
if (!ret) {
|
||||
alert.error("开始捕获失败,请检查连接");
|
||||
isCapturing.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 读取数据
|
||||
|
|
Loading…
Reference in New Issue