Skip to content

Commit

Permalink
feat(sdr): update WriteCalibrationTable delegate in AsvSdr
Browse files Browse the repository at this point in the history
Modified the WriteCalibrationTable delegate method to include a metadata parameter in AsvSdr. The changes include exception handling improvements and clearer variable naming. The try-catch block is enhanced for better exception management.
  • Loading branch information
asvol committed Nov 21, 2023
1 parent 9385c58 commit 60a9238
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Asv.Mavlink.Test/Microservices/AsvSdr/AsvSdrExTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ public async Task Client_upload_and_download_with_server_error()
metadata = null;
return false;
};
server.WriteCalibrationTable = (tableIndex, items) =>
server.WriteCalibrationTable = (tableIndex, metadata, items) =>
{
throw new Exception("FATAL");
};
Expand Down
7 changes: 7 additions & 0 deletions src/Asv.Mavlink/Microservices/AsvSdr/CalibrationTableRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class CalibrationTableMetadata
public CalibrationTableMetadata()
{

}
public CalibrationTableMetadata(AsvSdrCalibTableUploadStartPacket updated)
{
Updated = MavlinkTypesHelper.FromUnixTimeUs(updated.Payload.CreatedUnixUs);
}
public CalibrationTableMetadata(AsvSdrCalibTablePayload result)
{
Expand All @@ -25,6 +29,9 @@ public CalibrationTableMetadata(DateTime updated)
{
Updated = updated;
}



public DateTime Updated { get; set; }

public void Fill(AsvSdrCalibTablePayload payload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private async void OnCalibrationTableUploadStart(AsvSdrCalibTableUploadStartPack
var row = await Base.CallCalibrationTableUploadReadCallback(args.SystemId,args.ComponentId,args.Payload.RequestId,args.Payload.TableIndex,i,DisposeCancel).ConfigureAwait(false);
rows[i] = row;
}
WriteCalibrationTable(args.Payload.TableIndex, rows);
WriteCalibrationTable(args.Payload.TableIndex, new CalibrationTableMetadata(args), rows);
_status.Info($"Upload calibration [{args.Payload.TableIndex}] completed");
await Base.SendCalibrationAcc(args.Payload.RequestId, AsvSdrRequestAck.AsvSdrRequestAckOk).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Asv.Mavlink;
public delegate Task<MavResult> StopCalibrationDelegate(CancellationToken cancel);
public delegate bool TryReadCalibrationTableInfoDelegate(ushort tableIndex, out string? name, out ushort? size, out CalibrationTableMetadata? metadata);
public delegate bool TryReadCalibrationTableRowDelegate(ushort tableIndex, ushort rowIndex, out CalibrationTableRow? row);
public delegate void WriteCalibrationDelegate(ushort tableIndex, CalibrationTableRow[] items);
public delegate void WriteCalibrationDelegate(ushort tableIndex, CalibrationTableMetadata metadata, CalibrationTableRow[] items);


public interface IAsvSdrServerEx
Expand Down

0 comments on commit 60a9238

Please sign in to comment.