From be811ed4a2b3501fd196bf62ca4c63824d2c5226 Mon Sep 17 00:00:00 2001 From: Tomoki Date: Wed, 3 May 2023 00:11:43 +0900 Subject: [PATCH 01/19] enable to use type-A command --- .../command/plan_display/PlanTabPanel.tsx | 32 ++++++++- .../ClientApp/src/redux/plans/operations.ts | 12 +++- .../WINGS/Controllers/CommandController.cs | 38 +++++++++- .../WINGS/Services/Core/CommandService.cs | 70 ++++++++++++++++++- .../Core/Interfaces/ICommandService.cs | 2 + .../Manager/Interfaces/ITcPacketManager.cs | 2 +- .../Services/TMTC/Manager/TcPacketManager.cs | 4 +- .../Abstracts/TcPacketGeneratorBase.cs | 6 +- .../Abstracts/TmPacketAnalyzerBase.cs | 2 + .../Interfaces/ITcPacketGenerator.cs | 2 +- .../Processor/Interfaces/ITmPacketAnalyzer.cs | 2 + .../IsslCommonTcPacketGenerator.cs | 2 +- .../ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs | 10 +++ .../UserDefined/MOBC/MobcTcPacketGenerator.cs | 18 ++--- .../UserDefined/MOBC/MobcTmPacketAnalyzer.cs | 28 ++++++++ .../SecondaryObcTcPacketGenerator.cs | 2 +- .../SecondaryObcTmPacketAnalyzer.cs | 10 +++ 17 files changed, 216 insertions(+), 26 deletions(-) diff --git a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx index 84196fc..c0f4d87 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx @@ -22,6 +22,12 @@ import DialogActions from '@material-ui/core/DialogActions'; import { Dialog } from '@material-ui/core'; import { getOpid } from '../../../redux/operations/selectors'; import { finishEditCommandLineAction } from '../../../redux/plans/actions'; +import Radio from '@material-ui/core/Radio'; +import RadioGroup from '@material-ui/core/RadioGroup'; +import FormControlLabel from '@material-ui/core/FormControlLabel'; +import FormControl from '@material-ui/core/FormControl'; +import FormLabel from '@material-ui/core/FormLabel'; +import Toolbar from '@material-ui/core/Toolbar'; const useStyles = makeStyles( createStyles({ @@ -37,6 +43,10 @@ const useStyles = makeStyles( button: { width: 120 }, + cmdTypeField: { + fontSize: "10pt", + textAlign:"center" + }, activeTab: { height: 700, zIndex: 99, @@ -70,6 +80,7 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { const opid = getOpid(selector); const activePlanId = getActivePlanId(selector); + const [cmdType, setCmdType] = React.useState("Type-B"); const [showModal, setShowModal] = React.useState(false); const [text, setText] = React.useState(""); @@ -127,6 +138,10 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { } }; + const handleChange = (event: React.ChangeEvent) => { + setCmdType((event.target as HTMLInputElement).value); + }; + const handleTableClick = () => { textInput.current.focus(); } @@ -216,7 +231,7 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { const executeMultipleRequests = async () => { let row = selectedRow; do { - const exeret = await executeRequest(row); + const exeret = await executeRequest(row, cmdType); await sendCmdFileLine(row, exeret); if (content[row].request.method == "call") { break; @@ -316,7 +331,7 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { } } - const executeRequest = async (row: number): Promise => { + const executeRequest = async (row: number, cmdType: string): Promise => { const req = content[row].request; let exeret = false; switch (req.type) { @@ -372,7 +387,7 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { } } } - await dispatch(postCommand(row, req, paramsValue, commandret)); + await dispatch(postCommand(row, cmdType, req, paramsValue, commandret)); exeret = commandret[0]; break; @@ -519,6 +534,17 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { return ( <>
+ + + Data Type + + + } label="Type-A" /> + } label="Type-B" /> + + + +
{ } }; -export const postCommand = (row: number, req: Request, paramsValue: string[], ret: boolean[]) => { +export const postCommand = (row: number, cmdType: string, req: Request, paramsValue: string[], ret: boolean[]) => { return async (dispatch: Dispatch, getState: () => RootState) => { const opid = getState().operation.id; var body = JSON.parse(JSON.stringify(req.body)); @@ -33,7 +33,15 @@ export const postCommand = (row: number, req: Request, paramsValue: string[], re body.params[i].value = paramsValue[i]; } } - const res = await fetch(`/api/operations/${opid}/cmd`,{ + let cmd_uri :string; + if (cmdType == "Type-A") + { + cmd_uri = "cmd_typeA"; + } + else { + cmd_uri = "cmd"; + } + const res = await fetch(`/api/operations/${opid}/${cmd_uri}`,{ method: 'POST', headers: { 'Content-Type': 'application/json' diff --git a/aspnetapp/WINGS/Controllers/CommandController.cs b/aspnetapp/WINGS/Controllers/CommandController.cs index 5e75c14..9f83e58 100644 --- a/aspnetapp/WINGS/Controllers/CommandController.cs +++ b/aspnetapp/WINGS/Controllers/CommandController.cs @@ -14,10 +14,15 @@ namespace WINGS.Controllers public class CommandController : ControllerBase { private readonly ICommandService _commandService; + private readonly ITmtcHandlerFactory _tmtcHandlerFactory; + private static int _cmdWindow; + private static bool _getCmdWindowFromTlm; - public CommandController(ICommandService commandService) + public CommandController(ICommandService commandService, + ITmtcHandlerFactory tmtcHandlerFactory) { _commandService = commandService; + _tmtcHandlerFactory = tmtcHandlerFactory; } // GET: api/operations/f364../cmd @@ -27,6 +32,9 @@ public IActionResult GetAll(string id) try { var commands = _commandService.GetAllCommand(id); + _cmdWindow = _tmtcHandlerFactory.GetTmPacketAnalyzer(id).GetCmdWindow(); + _getCmdWindowFromTlm = false; + _commandService.InitializeTypeAStatus(id); return StatusCode(Status200OK, new { data = commands }); } @@ -51,6 +59,34 @@ public async Task Send(string id, [FromBody]JsonElement json) var ack = await _commandService.SendCommandAsync(id, command, commanderId); return StatusCode(Status200OK, new { ack = ack }); } + + // POST: api/operations/f364../cmd_typeA + [HttpPost("cmd_typeA")] + public async Task SendTypeA(string id, [FromBody]JsonElement json) + { + var cmdStr = json.GetProperty("command").ToString(); + var command = JsonSerializer.Deserialize(cmdStr, new JsonSerializerOptions{ + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + Converters = { new JsonStringEnumConverter() } + }); + var commanderId = ""; + + var channelId = UInt16.Parse(command.Code.Remove(0,2), System.Globalization.NumberStyles.HexNumber); + + bool ack; + + if (!_getCmdWindowFromTlm) + { + _cmdWindow = (int)_tmtcHandlerFactory.GetTmPacketAnalyzer(id).GetCmdWindow(); + _getCmdWindowFromTlm = true; + } + + var sendTypeATask = _commandService.SendTypeACommandAsync(id, command, commanderId, _cmdWindow); + _cmdWindow = (_cmdWindow + 1) & 0xff; + ack = await sendTypeATask; + + return StatusCode(Status200OK, new { ack = ack }); + } // POST: api/operations/f364../cmd/raw [HttpPost("cmd/raw")] diff --git a/aspnetapp/WINGS/Services/Core/CommandService.cs b/aspnetapp/WINGS/Services/Core/CommandService.cs index c3752b3..01b20d4 100644 --- a/aspnetapp/WINGS/Services/Core/CommandService.cs +++ b/aspnetapp/WINGS/Services/Core/CommandService.cs @@ -8,6 +8,7 @@ using WINGS.Data; using WINGS.Models; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; namespace WINGS.Services { @@ -19,11 +20,25 @@ public class CommandService : ICommandService private readonly IDbRepository _dbRepository; private readonly ICommandFileRepository _fileRepository; private readonly ICommandFileLogRepository _filelogRepository; + private readonly ILogger _logger; private static Dictionary> _indexesDict; + private static Dictionary _sendCmdDict; + private static bool _sendCommandFlag; + private int periodMilliSeconds = 200; // 200 ms + private static int _nextCmdWindow; + private static int _cacheCmdWindow; + private static readonly int _cmdWindowSize; + protected enum CmdType { TypeA = 0b0, TypeB = 0b1 }; + static CommandService() { _indexesDict = new Dictionary>(); + _sendCmdDict = new Dictionary(); + _sendCommandFlag = false; + _nextCmdWindow = 0x00; + _cacheCmdWindow = 0x00; + _cmdWindowSize = 256; } public CommandService(ApplicationDbContext dbContext, @@ -31,7 +46,8 @@ public CommandService(ApplicationDbContext dbContext, ITcPacketManager tcPacketManager, IDbRepository dbRepository, ICommandFileRepository fileRepository, - ICommandFileLogRepository filelogRepository) + ICommandFileLogRepository filelogRepository, + ILogger logger) { _dbContext = dbContext; _tmtcHandlerFactory = tmtcHandlerFactory; @@ -39,6 +55,7 @@ public CommandService(ApplicationDbContext dbContext, _dbRepository = dbRepository; _fileRepository = fileRepository; _filelogRepository = filelogRepository; + _logger = logger; } public IEnumerable GetAllCommand(string opid) @@ -53,7 +70,7 @@ public async Task SendCommandAsync(string opid, Command command, string co try { - _tcPacketManager.RegisterCommand(opid, command); + _tcPacketManager.RegisterCommand(opid, command, (byte)CmdType.TypeB, 0x00); var commandLog = CommandToLog(opid, command); _dbContext.CommandLogs.Add(commandLog); @@ -68,6 +85,55 @@ public async Task SendCommandAsync(string opid, Command command, string co } } + public async Task SendTypeACommandAsync(string opid, Command command, string commanderId, int cmdWindow) + { + var commandDb = new List(_tcPacketManager.GetCommandDb(opid)); + if (!IsParamsTypeCheckOk(command, commandDb)) return false; + + try + { + int reqCmdWindow = (int) _tmtcHandlerFactory.GetTmPacketAnalyzer(opid).GetCmdWindow(); + _tcPacketManager.RegisterCommand(opid, command, (byte)CmdType.TypeA, (byte)cmdWindow); + + var commandLog = CommandToLog(opid, command); + _dbContext.CommandLogs.Add(commandLog); + _sendCmdDict.Add(cmdWindow, command); + + for (int i = _cacheCmdWindow; i < ((_cacheCmdWindow>reqCmdWindow) ? (reqCmdWindow+_cmdWindowSize) : reqCmdWindow); i++) + { + _sendCmdDict.Remove(i%_cmdWindowSize); + _cacheCmdWindow = (i+1) % _cmdWindowSize; + } + + await _dbContext.SaveChangesAsync(); + + return true; + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + return false; + } + } + + public bool InitializeTypeAStatus(string opid) { + try + { + _sendCmdDict.Clear(); + return true; + } + catch (Exception ex) + { + _logger.LogError(ex, $"Error initializing Type-A status. {ex.ToString()}"); + return false; + } + } + + public int UpdateCmdWindow(int window) + { + return (window == 0xff)?0x00:window+1; + } + public void SendRawCommand(string opid, byte[] packet) { var data = new TcPacketData(){ diff --git a/aspnetapp/WINGS/Services/Core/Interfaces/ICommandService.cs b/aspnetapp/WINGS/Services/Core/Interfaces/ICommandService.cs index 773afe7..f4521ab 100644 --- a/aspnetapp/WINGS/Services/Core/Interfaces/ICommandService.cs +++ b/aspnetapp/WINGS/Services/Core/Interfaces/ICommandService.cs @@ -9,6 +9,8 @@ public interface ICommandService { IEnumerable GetAllCommand(string opid); Task SendCommandAsync(string opid, Command command, string commanderId); + Task SendTypeACommandAsync(string opid, Command command, string commanderId, int cmdWindow); + public bool InitializeTypeAStatus(string opid); void SendRawCommand(string opid, byte[] packet); Task AddCmdFileLineLog(string opid, CommandFileLineLog command_file_line_log, string commanderId); IEnumerable GetCommandFileIndexes(string opid); diff --git a/aspnetapp/WINGS/Services/TMTC/Manager/Interfaces/ITcPacketManager.cs b/aspnetapp/WINGS/Services/TMTC/Manager/Interfaces/ITcPacketManager.cs index d3a0aaa..9fead42 100644 --- a/aspnetapp/WINGS/Services/TMTC/Manager/Interfaces/ITcPacketManager.cs +++ b/aspnetapp/WINGS/Services/TMTC/Manager/Interfaces/ITcPacketManager.cs @@ -8,6 +8,6 @@ public interface ITcPacketManager void SetCommandDb(string opid, List commandDb); void RemoveOperation(string opid); List GetCommandDb(string opid); - void RegisterCommand(string opid, Command command); + void RegisterCommand(string opid, Command command, byte cmdType, byte cmdWindow); } } diff --git a/aspnetapp/WINGS/Services/TMTC/Manager/TcPacketManager.cs b/aspnetapp/WINGS/Services/TMTC/Manager/TcPacketManager.cs index 43b6e21..cc38f0e 100644 --- a/aspnetapp/WINGS/Services/TMTC/Manager/TcPacketManager.cs +++ b/aspnetapp/WINGS/Services/TMTC/Manager/TcPacketManager.cs @@ -33,9 +33,9 @@ public List GetCommandDb(string opid) return commandDb; } - public void RegisterCommand(string opid, Command command) + public void RegisterCommand(string opid, Command command, byte cmdType, byte cmdWindow) { - var data = _tmtcHandlerFactory.GetTcPacketGenerator(opid).GetTcPacketData(opid, command); + var data = _tmtcHandlerFactory.GetTcPacketGenerator(opid).GetTcPacketData(opid, command, cmdType, cmdWindow); _tmtcHandlerFactory.GetTmtcPacketService(opid).Send(data); } } diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TcPacketGeneratorBase.cs b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TcPacketGeneratorBase.cs index 95455a0..bca75cf 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TcPacketGeneratorBase.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TcPacketGeneratorBase.cs @@ -9,11 +9,11 @@ namespace WINGS.Services { public abstract class TcPacketGeneratorBase { - protected abstract byte[] GeneratePacket(Command command); + protected abstract byte[] GeneratePacket(Command command, byte cmdType, byte cmdWindow); - public TcPacketData GetTcPacketData(string opid, Command command) + public TcPacketData GetTcPacketData(string opid, Command command, byte cmdType, byte cmdWindow) { - var packet = GeneratePacket(command); + var packet = GeneratePacket(command, cmdType, cmdWindow); return new TcPacketData(){ Opid = opid, TcPacket = packet diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs index 606d990..e6029c2 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs @@ -17,6 +17,8 @@ public TmPacketAnalyzerBase(ITelemetryLogRepository logRepository) } public abstract Task AnalyzePacketAsync(TmPacketData data, List prevTelemetry); + public abstract byte GetCmdWindow(); + public abstract bool GetRetransmitFlag(); public virtual void RemoveOperation(string opid) { } diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITcPacketGenerator.cs b/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITcPacketGenerator.cs index 3ba9552..b434f04 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITcPacketGenerator.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITcPacketGenerator.cs @@ -4,6 +4,6 @@ namespace WINGS.Services { public interface ITcPacketGenerator { - TcPacketData GetTcPacketData(string opid, Command command); + TcPacketData GetTcPacketData(string opid, Command command, byte cmdType, byte cmdWindow); } } diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITmPacketAnalyzer.cs index 934fea9..8c1a9cb 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/Interfaces/ITmPacketAnalyzer.cs @@ -8,6 +8,8 @@ namespace WINGS.Services public interface ITmPacketAnalyzer { Task AnalyzePacketAsync(TmPacketData data, List prevTelemetry); + public byte GetCmdWindow(); + public bool GetRetransmitFlag(); void RemoveOperation(string opid); } } diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTcPacketGenerator.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTcPacketGenerator.cs index 394714e..a4aaf37 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTcPacketGenerator.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTcPacketGenerator.cs @@ -15,7 +15,7 @@ static IsslCommonTcPacketGenerator() command_count = 0; } - protected override byte[] GeneratePacket(Command command) + protected override byte[] GeneratePacket(Command command, byte cmdType, byte cmdWindow) { int paramsLen = GetParamsByteLength(command); var tcPktBdyLen = (UInt16)(TcPktCmdHdrLen + paramsLen); diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs index b0570ad..265c475 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs @@ -20,6 +20,16 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List> statictmPacket= new Dictionary>(); + private static byte cmdWindow = 0x00; + private static bool retransmitFlag = false; public MobcTmPacketAnalyzer(ITelemetryLogRepository logRepository) : base(logRepository) { @@ -27,6 +29,7 @@ private enum ClcwVer { Ver1 = 0b00 } private enum COPinEff { COP1 = 0b01 } private enum VCId { Default = 0b000000 } private enum Spare { Fixed = 0b00 } + private enum Retransmit {Flag = 0b1000} public override async Task AnalyzePacketAsync(TmPacketData data, List prevTelemetry) { @@ -157,6 +160,17 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List ccsdsdataList, List packetIdList, List realtimeFlagList, List TIList) { ccsdsdataList.Add(new TmPacketData{ Opid = opid, TmPacket = ccsdstmPacket }); @@ -225,6 +239,8 @@ protected bool AnalyzeFooter(byte[] ETX) if (!ChkCOPinEff(ETX, COPinEff.COP1)) { return false; } if (!ChkVCId(ETX, VCId.Default)) { return false; } if (!ChkSpare(ETX, Spare.Fixed)) { return false; } + retransmitFlag = SetRetransmitFlag(ETX, Retransmit.Flag); + cmdWindow = SetCmdWindow(ETX); return true; } @@ -287,7 +303,19 @@ private bool ChkSpare(byte[] ETX, Spare spare) return (ETX[pos] & mask) == val; } + private bool SetRetransmitFlag(byte[] ETX, Retransmit flag) + { + int pos = 2; + byte mask = 0b_0000_1000; + byte val = (byte) ((byte)flag); + return (ETX[pos] & mask) == val; + } + private byte SetCmdWindow(byte[] ETX) + { + int pos = 3; + return ETX[pos]; + } public override void RemoveOperation(string opid) { diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs index 465e360..880ae42 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs @@ -37,7 +37,7 @@ private enum TcpSeqFlag { Cont = 0, First = 1, Last = 2, Single = 3 } private enum TcpSeqCnt { Default = 0 } private enum TcpFmtId { Control = 1, User = 2, Memory = 3 } - protected override byte[] GeneratePacket(Command command) + protected override byte[] GeneratePacket(Command command, byte cmdType, byte cmdWindow) { int paramsLen = GetParamsByteLength(command); var tcpPktLen = (UInt16)(TcPktSecHdrLen + UserDataHdrLen + paramsLen); diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs index f8a5ab0..2e85290 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs @@ -29,6 +29,16 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List Date: Wed, 3 May 2023 21:04:56 +0900 Subject: [PATCH 02/19] enable to reflect state of radio button --- .../command/plan_display/OpenPlanDialog.tsx | 2 +- .../command/plan_display/PlanDisplayArea.tsx | 45 ++++++++++++++++++- .../command/plan_display/PlanTabPanel.tsx | 31 +++---------- .../WINGS/ClientApp/src/models/CommandPlan.ts | 3 +- .../ClientApp/src/redux/plans/actions.ts | 8 ++++ .../ClientApp/src/redux/plans/reducers.ts | 8 ++++ .../ClientApp/src/redux/plans/selectors.ts | 4 ++ .../ClientApp/src/redux/store/initialState.ts | 1 + 8 files changed, 72 insertions(+), 30 deletions(-) diff --git a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/OpenPlanDialog.tsx b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/OpenPlanDialog.tsx index 6d97ab5..1ef6f69 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/OpenPlanDialog.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/OpenPlanDialog.tsx @@ -45,7 +45,7 @@ const OpenPlanDialog = (props: OpenPlanDialogProps) => { }; const handleOk = () => { - if (values != []) { + if (values.length != 0) { indexes.forEach(index => { if (values.indexOf(index.id) >= 0) { dispatch(openPlan(index.id)); diff --git a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanDisplayArea.tsx b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanDisplayArea.tsx index 3707640..63ef7d1 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanDisplayArea.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanDisplayArea.tsx @@ -14,6 +14,14 @@ import OpenPlanDialog from './OpenPlanDialog'; import PlanTabPanel from './PlanTabPanel'; import IconButtonInTabs from '../../common/IconButtonInTabs'; import { UNPLANNED_ID } from '../../../constants'; +import Radio from '@material-ui/core/Radio'; +import RadioGroup from '@material-ui/core/RadioGroup'; +import FormControlLabel from '@material-ui/core/FormControlLabel'; +import FormControl from '@material-ui/core/FormControl'; +import FormLabel from '@material-ui/core/FormLabel'; +import Toolbar from '@material-ui/core/Toolbar'; +import { getCmdType } from '../../../redux/plans/selectors'; +import { setCmdTypeAction } from '../../../redux/plans/actions'; const useStyles = makeStyles( createStyles({ @@ -46,6 +54,10 @@ const useStyles = makeStyles( width: '80%', maxHeight: 435, }, + cmdTypeField: { + fontSize: "10pt", + textAlign:"center" + }, planTab: { width: 700 } @@ -71,6 +83,7 @@ const PlanDisplayArea = () => { const planContents = getPlanContents(selector); const inExecution = getInExecution(selector); const value = openedIds.indexOf(activePlanId); + const [cmdType, setCmdType] = React.useState(getCmdType(selector)); const handleDialogOpen = () => { if (!inExecution) { @@ -89,6 +102,12 @@ const PlanDisplayArea = () => { } }; + const handleChange = (event: React.ChangeEvent) => { + let cmdType = (event.target as HTMLInputElement).value + setCmdType(cmdType); + dispatch(setCmdTypeAction(cmdType)); + }; + const closePlan = (id: string) => { dispatch(closePlanAction(id)); } @@ -135,9 +154,20 @@ const PlanDisplayArea = () => {
+ + + Data Type + + + } label="Type-A" /> + } label="Type-B" /> + + + + {planIndexes.length > 0 && ( planIndexes.map((index,i) => ( - + )) )}
@@ -182,9 +212,20 @@ const PlanDisplayArea = () => {
+ + + Data Type + + + } label="Type-A" /> + } label="Type-B" /> + + + + {planIndexes.length > 0 && ( planIndexes.map((index,i) => ( - + )) )}
diff --git a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx index c0f4d87..6054d5d 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx @@ -22,12 +22,6 @@ import DialogActions from '@material-ui/core/DialogActions'; import { Dialog } from '@material-ui/core'; import { getOpid } from '../../../redux/operations/selectors'; import { finishEditCommandLineAction } from '../../../redux/plans/actions'; -import Radio from '@material-ui/core/Radio'; -import RadioGroup from '@material-ui/core/RadioGroup'; -import FormControlLabel from '@material-ui/core/FormControlLabel'; -import FormControl from '@material-ui/core/FormControl'; -import FormLabel from '@material-ui/core/FormLabel'; -import Toolbar from '@material-ui/core/Toolbar'; const useStyles = makeStyles( createStyles({ @@ -48,13 +42,13 @@ const useStyles = makeStyles( textAlign:"center" }, activeTab: { - height: 700, + height: 900, zIndex: 99, position: "absolute", backgroundColor: "#212121" }, inactiveTab: { - height: 700, + height: 900, zIndex: 1, position: "absolute", backgroundColor: "#212121" @@ -67,11 +61,12 @@ export interface PlanTabPanelProps { value: number, index: number, name: string, - content: CommandPlanLine[] + content: CommandPlanLine[], + cmdType: string } const PlanTabPanel = (props: PlanTabPanelProps) => { - const {value, index, name, content } = props; + const {value, index, name, content, cmdType } = props; const classes = useStyles(); const dispatch = useDispatch(); const selector = useSelector((state: RootState) => state); @@ -80,7 +75,6 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { const opid = getOpid(selector); const activePlanId = getActivePlanId(selector); - const [cmdType, setCmdType] = React.useState("Type-B"); const [showModal, setShowModal] = React.useState(false); const [text, setText] = React.useState(""); @@ -138,10 +132,6 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { } }; - const handleChange = (event: React.ChangeEvent) => { - setCmdType((event.target as HTMLInputElement).value); - }; - const handleTableClick = () => { textInput.current.focus(); } @@ -534,17 +524,6 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { return ( <>
- - - Data Type - - - } label="Type-A" /> - } label="Type-B" /> - - - -
{ return { @@ -155,3 +156,10 @@ export const cancelEditCommandLineAction = (row: number) => { payload: row } }; + +export const setCmdTypeAction = (cmdType: string) => { + return { + type: SET_COMMAND_TYPE, + payload: cmdType + } +}; diff --git a/aspnetapp/WINGS/ClientApp/src/redux/plans/reducers.ts b/aspnetapp/WINGS/ClientApp/src/redux/plans/reducers.ts index 3d3b57c..7d837ab 100644 --- a/aspnetapp/WINGS/ClientApp/src/redux/plans/reducers.ts +++ b/aspnetapp/WINGS/ClientApp/src/redux/plans/reducers.ts @@ -24,6 +24,7 @@ type Actions = | ReturnType | ReturnType | ReturnType + | ReturnType | ReturnType ; @@ -336,6 +337,13 @@ export const PlansReducer = (state = initialState.plans, action: Actions) => { } } + case Actions.SET_COMMAND_TYPE: { + return { + ...state, + cmdType: action.payload + } + } + case OperationActions.LEAVE_OPERATION: { return initialState.plans; } diff --git a/aspnetapp/WINGS/ClientApp/src/redux/plans/selectors.ts b/aspnetapp/WINGS/ClientApp/src/redux/plans/selectors.ts index e51960a..06c2a3f 100644 --- a/aspnetapp/WINGS/ClientApp/src/redux/plans/selectors.ts +++ b/aspnetapp/WINGS/ClientApp/src/redux/plans/selectors.ts @@ -49,3 +49,7 @@ export const getInExecution = createSelector( state => state.inExecution ); +export const getCmdType = createSelector( + [plansSelector], + state => state.cmdType +); diff --git a/aspnetapp/WINGS/ClientApp/src/redux/store/initialState.ts b/aspnetapp/WINGS/ClientApp/src/redux/store/initialState.ts index 269cc56..3e066d0 100644 --- a/aspnetapp/WINGS/ClientApp/src/redux/store/initialState.ts +++ b/aspnetapp/WINGS/ClientApp/src/redux/store/initialState.ts @@ -59,6 +59,7 @@ const initialState: RootState = { cmdFileInfoIndex: "" }], cmdFileVariables: [], + cmdType: "Type-B", openedIds: [UNPLANNED_ID], activeId: UNPLANNED_ID, selectedRow: -1, From 6e8fb27465afee7b12fe6fcc3ae8b3257f037c34 Mon Sep 17 00:00:00 2001 From: Tomoki Date: Wed, 3 May 2023 21:11:50 +0900 Subject: [PATCH 03/19] fix height --- .../src/components/command/plan_display/PlanTabPanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx index 6054d5d..573eeec 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx @@ -42,13 +42,13 @@ const useStyles = makeStyles( textAlign:"center" }, activeTab: { - height: 900, + height: 700, zIndex: 99, position: "absolute", backgroundColor: "#212121" }, inactiveTab: { - height: 900, + height: 700, zIndex: 1, position: "absolute", backgroundColor: "#212121" From c5b9235d969d2830e013ca58f47956c1b82004e7 Mon Sep 17 00:00:00 2001 From: Tomoki Date: Wed, 28 Jun 2023 10:51:31 +0900 Subject: [PATCH 04/19] fix UdCmdType --- .../UserDefined/MOBC/MobcTcPacketGenerator.cs | 10 +++++----- .../SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTcPacketGenerator.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTcPacketGenerator.cs index 5cc79a4..5726143 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTcPacketGenerator.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTcPacketGenerator.cs @@ -28,7 +28,7 @@ public class MobcTcPacketGenerator : TcPacketGeneratorBase, ITcPacketGenerator // enum // User Data - private enum UdCmdType { Dc = 1, Sm = 2 } + private enum UdCmdType { Unknown = 0, Dc = 1, Sm = 2 } private enum UdExeType { Realtime = 0x00, Timeline = 0x01, Macro = 0x02, UnixTimeline = 0x04, MobcRealtime = 0x10, MobcTimeline = 0x11, MobcMacro = 0x12, MobcUnixTimeline = 0x14, AobcRealtime = 0x20, AobcTimeline = 0x21, AobcMacro = 0x22, AobcUnixTimeline = 0x24, TobcRealtime = 0x30, TobcTimeline = 0x31, TobcMacro = 0x32, TobcUnixTimeline = 0x34} // TC Packet @@ -38,7 +38,7 @@ private enum TcpSecHdrFlag { Absent = 0, Present = 1 } private enum TcpApid { MobcCmd = 0x210, AobcCmd = 0x211, TobcCmd = 0x212 } private enum TcpSeqFlag { Cont = 0, First = 1, Last = 2, Single = 3 } private enum TcpSeqCnt { Default = 0 } - private enum TcpFmtId { Control = 1, User = 2, Memory = 3 } + private enum TcpSecondaryHeaderVer { Unknown = 0, Version1 = 1 } // TC Segment private enum TcsgmSeqFlag { First = 0b01, Continuing = 0b00, Last = 0b10, No = 0b11 } @@ -88,10 +88,10 @@ protected override byte[] GeneratePacket(Command command, byte cmdType, byte cmd SetTcpSeqFlag(packet, TcpSeqFlag.Single); SetTcpSeqCnt(packet, TcpSeqCnt.Default); SetTcpPktLen(packet, tcpPktLen); - SetTcpFmtId(packet, TcpFmtId.Control); + SetTcpSecondaryHeaderVer(packet, TcpSecondaryHeaderVer.Version1); // User Data - SetUdCmdType(packet, UdCmdType.Sm); + SetUdCmdType(packet, UdCmdType.Unknown); SetUdChannelId(packet, channelId); SetUdExeType(packet, exeType); SetUdTi(packet, exeType, command); @@ -372,7 +372,7 @@ private void SetTcpPktLen(byte[] packet, UInt16 len) val = (byte)(z_origin & 0xff); packet[pos+1] = val; } - private void SetTcpFmtId(byte[] packet, TcpFmtId id) + private void SetTcpSecondaryHeaderVer(byte[] packet, TcpSecondaryHeaderVer id) { int pos = TcPktPos + 6; packet[pos] = (byte)id; diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs index 880ae42..26b2b79 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketGenerator.cs @@ -25,7 +25,7 @@ public class SecondaryObcTcPacketGenerator : TcPacketGeneratorBase, ITcPacketGen // enum // User Data - private enum UdCmdType { Dc = 1, Sm = 2 } + private enum UdCmdType { Unknown = 0, Dc = 1, Sm = 2 } private enum UdExeType { Realtime = 0, Timeline = 1, Macro = 2 ,UnixTimeline = 4 } // TC Packet @@ -35,7 +35,7 @@ private enum TcpSecHdrFlag { Absent = 0, Present = 1 } private enum TcpApid { MobcCmd = 0x210, AobcCmd = 0x211, TobcCmd = 0x212 } private enum TcpSeqFlag { Cont = 0, First = 1, Last = 2, Single = 3 } private enum TcpSeqCnt { Default = 0 } - private enum TcpFmtId { Control = 1, User = 2, Memory = 3 } + private enum TcpSecondaryHeaderVer { Unknown = 0, Version1 = 1 } protected override byte[] GeneratePacket(Command command, byte cmdType, byte cmdWindow) { @@ -63,10 +63,10 @@ protected override byte[] GeneratePacket(Command command, byte cmdType, byte cmd SetTcpSeqFlag(packet, TcpSeqFlag.Single); SetTcpSeqCnt(packet, TcpSeqCnt.Default); SetTcpPktLen(packet, tcpPktLen); - SetTcpFmtId(packet, TcpFmtId.Control); + SetTcpSecondaryHeaderVer(packet, TcpSecondaryHeaderVer.Version1); // User Data - SetUdCmdType(packet, UdCmdType.Sm); + SetUdCmdType(packet, UdCmdType.Unknown); SetUdChannelId(packet, channelId); SetUdExeType(packet, exeType); SetUdTi(packet, exeType, command); @@ -187,7 +187,7 @@ private void SetTcpPktLen(byte[] packet, UInt16 len) val = (byte)(z_origin & 0xff); packet[pos+1] = val; } - private void SetTcpFmtId(byte[] packet, TcpFmtId id) + private void SetTcpSecondaryHeaderVer(byte[] packet, TcpSecondaryHeaderVer id) { int pos = TcPktPos + 6; packet[pos] = (byte)id; From e1988c0d35622d313ebef0bf8dda4e2898c4651e Mon Sep 17 00:00:00 2001 From: Tomoki Date: Thu, 23 Feb 2023 11:48:20 +0900 Subject: [PATCH 05/19] add config.json --- aspnetapp/WINGS/Models/TlmCmdFileConfig.cs | 8 +++++ .../WINGS/Services/Core/CommandService.cs | 14 +++++---- .../Services/Core/TlmCmdFileConfigBuilder.cs | 30 +++++++++++++++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs b/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs index 75c70a2..2ac62d9 100644 --- a/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs +++ b/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs @@ -12,6 +12,13 @@ public class TlmCmdFileLocationInfo public string DirPath { get; set; } } + public class TlmConfigurationInfo + { + public string ApId { get; set; } + public string CsvName { get; set; } + public string CompoName { get; set; } + } + public class TlmCmdFileConfig { public TlmCmdFileLocation Location { get; set; } @@ -19,5 +26,6 @@ public class TlmCmdFileConfig public List TlmDBInfo { get; set; } public List CmdFileInfo { get; set; } public TlmCmdFileLocationInfo LayoutInfo { get; set; } + public List TlmConfigInfo { get; set; } } } diff --git a/aspnetapp/WINGS/Services/Core/CommandService.cs b/aspnetapp/WINGS/Services/Core/CommandService.cs index 01b20d4..96a8afb 100644 --- a/aspnetapp/WINGS/Services/Core/CommandService.cs +++ b/aspnetapp/WINGS/Services/Core/CommandService.cs @@ -9,6 +9,7 @@ using WINGS.Models; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Hosting; namespace WINGS.Services { @@ -21,6 +22,7 @@ public class CommandService : ICommandService private readonly ICommandFileRepository _fileRepository; private readonly ICommandFileLogRepository _filelogRepository; private readonly ILogger _logger; + private readonly IWebHostEnvironment _env; private static Dictionary> _indexesDict; private static Dictionary _sendCmdDict; private static bool _sendCommandFlag; @@ -47,7 +49,8 @@ public CommandService(ApplicationDbContext dbContext, IDbRepository dbRepository, ICommandFileRepository fileRepository, ICommandFileLogRepository filelogRepository, - ILogger logger) + ILogger logger, + IWebHostEnvironment env) { _dbContext = dbContext; _tmtcHandlerFactory = tmtcHandlerFactory; @@ -56,6 +59,7 @@ public CommandService(ApplicationDbContext dbContext, _fileRepository = fileRepository; _filelogRepository = filelogRepository; _logger = logger; + _env = env; } public IEnumerable GetAllCommand(string opid) @@ -177,7 +181,7 @@ public async Task GetCommandFileAsync(string opid, int cmdFileInfoI { throw new ResourceNotFoundException("The command file is not found"); } - var config = await new TlmCmdFileConfigBuilder(_dbContext).Build(opid); + var config = await new TlmCmdFileConfigBuilder(_dbContext, _env).Build(opid); var commandDb = _tcPacketManager.GetCommandDb(opid); var file = await _fileRepository.LoadCommandFileAsync(config, index, commandDb); return file; @@ -193,7 +197,7 @@ public async Task GetCommandRowAsync(string opid, int cmdFileInfoIndex, { throw new ResourceNotFoundException("The command file is not found"); } - var config = await new TlmCmdFileConfigBuilder(_dbContext).Build(opid); + var config = await new TlmCmdFileConfigBuilder(_dbContext, _env).Build(opid); var line = await _fileRepository.GetCommandRowAsync(config, index, row); return line; } @@ -209,7 +213,7 @@ public async Task LoadCommandRowAsync(string opid, int cmdFileI { throw new ResourceNotFoundException("The command file is not found"); } - var config = await new TlmCmdFileConfigBuilder(_dbContext).Build(opid); + var config = await new TlmCmdFileConfigBuilder(_dbContext, _env).Build(opid); var commandDb = _tcPacketManager.GetCommandDb(opid); var commandFileLine = await _fileRepository.LoadCommandRowAsync(config, index, commandDb, row, text); return commandFileLine; @@ -253,7 +257,7 @@ public async Task ReconfigureCommandFileAsync(string opid) throw new ResourceNotFoundException("The operation is not running"); } _indexesDict.Remove(opid); - var config = await new TlmCmdFileConfigBuilder(_dbContext).Build(opid); + var config = await new TlmCmdFileConfigBuilder(_dbContext, _env).Build(opid); var indexes = await _fileRepository.LoadCommandFileIndexesAsync(config); _indexesDict.Add(opid, indexes); } diff --git a/aspnetapp/WINGS/Services/Core/TlmCmdFileConfigBuilder.cs b/aspnetapp/WINGS/Services/Core/TlmCmdFileConfigBuilder.cs index b1817f4..cc029af 100644 --- a/aspnetapp/WINGS/Services/Core/TlmCmdFileConfigBuilder.cs +++ b/aspnetapp/WINGS/Services/Core/TlmCmdFileConfigBuilder.cs @@ -2,9 +2,14 @@ using System.Threading.Tasks; using System.Collections.Generic; using System.Linq; +using System.IO; +using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; using Microsoft.EntityFrameworkCore; using WINGS.Data; using WINGS.Models; +using Microsoft.AspNetCore.Hosting; namespace WINGS.Services { @@ -12,9 +17,12 @@ public class TlmCmdFileConfigBuilder : ITlmCmdFileConfigBuilder { private readonly ApplicationDbContext _dbContext; - public TlmCmdFileConfigBuilder(ApplicationDbContext dbContext) + private readonly IWebHostEnvironment _env; + + public TlmCmdFileConfigBuilder(ApplicationDbContext dbContext, IWebHostEnvironment env) { _dbContext = dbContext; + _env = env; } /// @@ -32,16 +40,34 @@ public async Task Build(string opid) CmdDBInfo = new List(), TlmDBInfo = new List(), CmdFileInfo = new List(), - LayoutInfo = new TlmCmdFileLocationInfo() + LayoutInfo = new TlmCmdFileLocationInfo(), + TlmConfigInfo = new List() }; + static List CreateConfigInfo(string filePath, string encodingName) + { + StreamReader sr = new StreamReader(filePath, Encoding.GetEncoding(encodingName)); + string configStr = sr.ReadToEnd(); + sr.Close(); + + List configJson = JsonSerializer.Deserialize>(configStr, new JsonSerializerOptions{ + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + Converters = { new JsonStringEnumConverter() } + }); + + return configJson; + } + switch (config.Location) { case TlmCmdFileLocation.Local: + string tlmConfigDirPath = Path.Combine(_env.ContentRootPath, operation.Component.LocalDirPath, "tlmdb/config.json"); + config.CmdDBInfo.Add(new TlmCmdFileLocationInfo() { DirPath = operation.Component.LocalDirPath }); config.TlmDBInfo.Add(new TlmCmdFileLocationInfo() { DirPath = operation.Component.LocalDirPath }); config.CmdFileInfo.Add(new TlmCmdFileLocationInfo() { DirPath = operation.Component.LocalDirPath }); config.LayoutInfo = new TlmCmdFileLocationInfo() { DirPath = operation.Component.LocalDirPath }; + config.TlmConfigInfo = CreateConfigInfo(tlmConfigDirPath, "utf-8"); break; default: From 8a8f693f5fb4f64c5c73ce795b30a960bd2ecf4e Mon Sep 17 00:00:00 2001 From: Tomoki Date: Thu, 23 Feb 2023 12:49:27 +0900 Subject: [PATCH 06/19] enable to identify ApId from csv Name --- aspnetapp/WINGS/Data/TelemetryDbRepository.cs | 7 +++++-- aspnetapp/WINGS/Models/Telemetry.cs | 2 ++ aspnetapp/WINGS/Models/TlmCmdFileConfig.cs | 1 - .../TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/aspnetapp/WINGS/Data/TelemetryDbRepository.cs b/aspnetapp/WINGS/Data/TelemetryDbRepository.cs index 9f14b79..c5f84de 100644 --- a/aspnetapp/WINGS/Data/TelemetryDbRepository.cs +++ b/aspnetapp/WINGS/Data/TelemetryDbRepository.cs @@ -44,7 +44,7 @@ public async Task> LoadAllFilesAsync(TlmCmdFileConf await sem.WaitAsync(); try { - return await LoadFileAsync(config.Location, c, filePath); + return await LoadFileAsync(config.Location, c, filePath, config.TlmConfigInfo); } finally { @@ -64,7 +64,7 @@ public async Task> LoadAllFilesAsync(TlmCmdFileConf return telemetryDb; } - private async Task LoadFileAsync(TlmCmdFileLocation location, TlmCmdFileLocationInfo tlmDBInfo, string filePath) + private async Task LoadFileAsync(TlmCmdFileLocation location, TlmCmdFileLocationInfo tlmDBInfo, string filePath, List tlmConfigInfo) { string[] cols; var reader = await GetDbFileReaderAsync(location, tlmDBInfo, filePath); @@ -76,12 +76,15 @@ private async Task LoadFileAsync(TlmCmdFileLocation location, T cols = reader.ReadLine().Split(","); var packetId = cols[2]; var packetName = Path.GetFileNameWithoutExtension(filePath); + var tlmConfig = tlmConfigInfo.Find(tlmConfig => packetName.Contains(tlmConfig.CompoName)); if (packetName.IndexOf("_TLM_DB_") != -1) { packetName = packetName.Substring(packetName.IndexOf("_TLM_DB_") + 8); } var packetInfo = new PacketInfo(){ + ApId = tlmConfig.ApId, Id = packetId, + CompoName = tlmConfig.CompoName, Name = packetName, IsRealtimeData = true, // add packet only for realtime tlm (record tlms are registered when SetTelemetryValuesAsync() in TmPacketAnalyzerBase.cs is called) IsRestricted = false diff --git a/aspnetapp/WINGS/Models/Telemetry.cs b/aspnetapp/WINGS/Models/Telemetry.cs index 98a77c1..696d441 100644 --- a/aspnetapp/WINGS/Models/Telemetry.cs +++ b/aspnetapp/WINGS/Models/Telemetry.cs @@ -17,7 +17,9 @@ public class TelemetryPacket } public class PacketInfo { + public string ApId { get; set; } public string Id { get; set; } + public string CompoName { get; set; } public string Name { get; set; } public bool IsRealtimeData { get; set; } public bool IsRestricted { get; set; } diff --git a/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs b/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs index 2ac62d9..62e6b30 100644 --- a/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs +++ b/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs @@ -15,7 +15,6 @@ public class TlmCmdFileLocationInfo public class TlmConfigurationInfo { public string ApId { get; set; } - public string CsvName { get; set; } public string CompoName { get; set; } } diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs index e6029c2..76201af 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs @@ -41,7 +41,9 @@ protected async Task SetTelemetryValuesAsync(TmPacketData data, string pac var targetRealtime = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == true)); var packetInfo = new PacketInfo(){ + ApId = targetRealtime.PacketInfo.ApId, Id = targetRealtime.PacketInfo.Id, + CompoName = targetRealtime.PacketInfo.CompoName, Name = targetRealtime.PacketInfo.Name, IsRealtimeData = false }; From a115a156fd930b442ba5db7ac3be8b5745c1b5af Mon Sep 17 00:00:00 2001 From: Tomoki Date: Thu, 23 Feb 2023 13:09:49 +0900 Subject: [PATCH 07/19] try to use apid to detect telemetry packet --- .../Abstracts/TmPacketAnalyzerBase.cs | 8 ++++---- .../ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs | 18 +++++++++++++++++- .../UserDefined/MOBC/MobcTmPacketAnalyzer.cs | 19 ++++++++++++++----- .../SecondaryObcTmPacketAnalyzer.cs | 18 +++++++++++++++++- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs index 76201af..32c3ac8 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs @@ -23,19 +23,19 @@ public virtual void RemoveOperation(string opid) { } - protected async Task SetTelemetryListValuesAsync(List dataList, List packetIdList, List realtimeFlagList, List TIList, List prevTelemetry) + protected async Task SetTelemetryListValuesAsync(List dataList, List apIdList, List packetIdList, List realtimeFlagList, List TIList, List prevTelemetry) { for (int i = 0; i < dataList.Count(); i++) { - await SetTelemetryValuesAsync(dataList[i], packetIdList[i], realtimeFlagList[i], TIList[i], prevTelemetry); + await SetTelemetryValuesAsync(dataList[i], apIdList[i], packetIdList[i], realtimeFlagList[i], TIList[i], prevTelemetry); } return true; } - protected async Task SetTelemetryValuesAsync(TmPacketData data, string packetId, bool isRealtimeData, UInt32 TI, List prevTelemetry) + protected async Task SetTelemetryValuesAsync(TmPacketData data, string apId, string packetId, bool isRealtimeData, UInt32 TI, List prevTelemetry) { var opid = data.Opid; - var target = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == isRealtimeData)); + var target = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.ApId == apId) && (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == isRealtimeData)); if (target == null && isRealtimeData == false) // case for the first time of recordtlm packet { var targetRealtime = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == true)); diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs index 265c475..cba9166 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs @@ -14,10 +14,26 @@ public IsslCommonTmPacketAnalyzer(ITelemetryLogRepository logRepository) : base( public override async Task AnalyzePacketAsync(TmPacketData data, List prevTelemetry) { + var apId = GetApId(data.TmPacket); var packetId = GetPacketId(data.TmPacket); var isRealtimeData = true; UInt32 TI = 0; - return await SetTelemetryValuesAsync(data, packetId, isRealtimeData, TI, prevTelemetry); + return await SetTelemetryValuesAsync(data, apId, packetId, isRealtimeData, TI, prevTelemetry); + } + + private UInt16 CombiteBytes(byte[] bytes, int pos) + { + UInt16 byte1 = (UInt16)bytes[pos]; + UInt16 byte2 = (UInt16)bytes[pos + 1]; + UInt16 byte1s = (UInt16)(byte1 << 8); + return (UInt16)(byte1s + byte2); + } + + private string GetApId(byte[] packet) + { + //packet : CCSDS Packet + int pos = 0; + return string.Format("0x{0:x3}", CombiteBytes(packet, pos) & 0b_0000_0111_1111_1111); } public override byte GetCmdWindow() diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs index 7e942e7..91e485a 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs @@ -49,6 +49,7 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List(); + var apIdList = new List(); var packetIdList = new List(); var realtimeFlagList = new List(); var TIList = new List(); @@ -81,7 +82,7 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List AnalyzePacketAsync(TmPacketData data, List AnalyzePacketAsync(TmPacketData data, List AnalyzePacketAsync(TmPacketData data, List ccsdsdataList, List packetIdList, List realtimeFlagList, List TIList) + private void AddTelemetryList(string opid, byte[] ccsdstmPacket, List ccsdsdataList, List apIdList, List packetIdList, List realtimeFlagList, List TIList) { ccsdsdataList.Add(new TmPacketData{ Opid = opid, TmPacket = ccsdstmPacket }); + apIdList.Add(GetApId(ccsdstmPacket)); packetIdList.Add(GetPacketId(ccsdstmPacket)); realtimeFlagList.Add(GetRealTimeFlag(ccsdstmPacket)); TIList.Add(GetTI(ccsdstmPacket)); @@ -194,6 +196,13 @@ private UInt16 CombiteBytesGetLen(byte[] bytes, int pos) return (UInt16)(byte1s + byte2 + 1); //起算 } + private string GetApId(byte[] packet) + { + //packet : CCSDS Packet + int pos = 0; + return string.Format("0x{0:x3}", CombiteBytes(packet, pos) & 0b_0000_0111_1111_1111); + } + private string GetPacketId(byte[] packet) { //packet : CCSDS Packet diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs index 2e85290..f657bbd 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs @@ -23,10 +23,26 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List Date: Thu, 23 Feb 2023 22:50:01 +0900 Subject: [PATCH 08/19] edit frontend to use apId --- .../command/plan_display/PlanTabPanel.tsx | 2 +- .../telemetry/view_display/GraphTabPanel.tsx | 8 +++--- .../view_display/OpenGraphTabDialog.tsx | 2 +- .../view_display/OpenPacketTabDialog.tsx | 2 +- .../telemetry/view_display/OpenViewDialog.tsx | 2 +- .../telemetry/view_display/PacketTabPanel.tsx | 2 +- .../WINGS/ClientApp/src/models/Telemetry.ts | 12 +++++++-- .../ClientApp/src/models/TelemetryView.ts | 4 ++- .../src/redux/operations/operations.ts | 4 +-- .../src/redux/telemetries/reducers.ts | 27 ++++++++++++++++--- 10 files changed, 47 insertions(+), 18 deletions(-) diff --git a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx index 573eeec..b540dfe 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/command/plan_display/PlanTabPanel.tsx @@ -245,7 +245,7 @@ const PlanTabPanel = (props: PlanTabPanelProps) => { outcome.value = cmdFileVariables[variableIndex].value; outcome.isSuccess = true; } else if (variableName.indexOf('.') > -1) { - var tlms = getLatestTelemetries(selector)[variableName.split('.')[0]]; + var tlms = getLatestTelemetries(selector)[variableName.split('.')[0]][variableName.split('.')[1]]; if (tlms.findIndex(index => index.telemetryInfo.name === variableName) >= 0) { variableIndex = tlms.findIndex(index => index.telemetryInfo.name === variableName); } else if (tlms.findIndex(index => index.telemetryInfo.name === variableName.split('.').slice(1).join('.')) >= 0) { diff --git a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx index f97bbcf..803bbbe 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx @@ -74,7 +74,7 @@ const GraphTabPanel = (props: GraphTabPanelProps) => { const selector = useSelector((state: RootState) => state); const classes = useStyles(); const dispatch = useDispatch(); - const telemetryHistories = getTelemetryHistories(selector)[tab.name]; + const telemetryHistories = getTelemetryHistories(selector); const [dataType, setDataType] = React.useState(tab.dataType); const [dataLength, setDataLength] = React.useState(tab.dataLength); @@ -111,7 +111,7 @@ const GraphTabPanel = (props: GraphTabPanelProps) => { },[setDataLength]); const inputYlabelMin = React.useCallback((event) => { - if (Number(event.target.value) != NaN){ + if (!isNaN(Number(event.target.value))){ setYlabelMin(event.target.value); } else{ @@ -120,7 +120,7 @@ const GraphTabPanel = (props: GraphTabPanelProps) => { },[setYlabelMin]); const inputYlabelMax = React.useCallback((event) => { - if (Number(event.target.value) != NaN){ + if (!isNaN(Number(event.target.value))){ setYlabelMax(event.target.value); } else{ @@ -133,7 +133,7 @@ const GraphTabPanel = (props: GraphTabPanelProps) => { let isFirstValueSet = false; tab.selectedTelemetries.forEach((telemetryName,index) =>{ - const selectedTelemetryHistory = telemetryHistories.find(element => element.telemetryInfo.name == telemetryName); + const selectedTelemetryHistory = telemetryHistories[tab.compoName][tab.name].find(element => element.telemetryInfo.name == telemetryName); if (selectedTelemetryHistory != undefined) { let tlmDataTmp: number[] = []; let tlmLabelTmp: string[] = []; diff --git a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenGraphTabDialog.tsx b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenGraphTabDialog.tsx index 9081112..859ff79 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenGraphTabDialog.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenGraphTabDialog.tsx @@ -38,7 +38,7 @@ const OpenGraphTabDialog = (props: OpenGraphTabDialogProps) => { const dispatch = useDispatch(); const formGroupRef = React.useRef(null); - const telemetryHistories = getTelemetryHistories(selector)[tab.name]; + const telemetryHistories = getTelemetryHistories(selector)[tab.compoName][tab.name]; const telemetryOptions: SelectOption[] = telemetryHistories.map(telemetryHistory => ({ id: telemetryHistory.telemetryInfo.name, name: telemetryHistory.telemetryInfo.name })); diff --git a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenPacketTabDialog.tsx b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenPacketTabDialog.tsx index 8d88181..6f4e837 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenPacketTabDialog.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenPacketTabDialog.tsx @@ -39,7 +39,7 @@ const OpenPacketTabDialog = (props: OpenPacketTabDialogProps) => { const formGroupRef = React.useRef(null); - const latestTelemetries = getLatestTelemetries(selector)[tab.name]; + const latestTelemetries = getLatestTelemetries(selector)[tab.compoName][tab.name]; const telemetryOptions: SelectOption[] = latestTelemetries.map(latestTelemetry => ({id:latestTelemetry.telemetryInfo.name, name:latestTelemetry.telemetryInfo.name})); diff --git a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenViewDialog.tsx b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenViewDialog.tsx index 402bd74..753451c 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenViewDialog.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/OpenViewDialog.tsx @@ -77,7 +77,7 @@ const OpenViewDialog = (props: OpenViewDialogProps) => { } if (type === "packet"){ let telemetryShowed :string[] = []; - let tlms = getLatestTelemetries(selector)[element.name]; + let tlms = getLatestTelemetries(selector)[element.compoName][element.name]; tlms.forEach(tlm => { telemetryShowed.push(tlm.telemetryInfo.name); }) diff --git a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/PacketTabPanel.tsx b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/PacketTabPanel.tsx index c83b8e9..f2f09e4 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/PacketTabPanel.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/PacketTabPanel.tsx @@ -108,7 +108,7 @@ const PacketTabPanel = (props: PacketTabPanelProps) => { const selector = useSelector((state: RootState) => state); const classes = useStyles(); const dispatch = useDispatch(); - const tlms = getLatestTelemetries(selector)[tab.name]; + const tlms = getLatestTelemetries(selector)[tab.compoName][tab.name]; const selectedTelemetries = tab.selectedTelemetries; const tlmClassList: string[] = [tab.name]; const tlmColor = getTelemetryColor(selector); diff --git a/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts b/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts index 2a24051..c02ca79 100644 --- a/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts +++ b/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts @@ -37,7 +37,9 @@ export type TelemetryValue = { export type TelemetryPacket = { packetInfo: { + apId: string, id: string, + compoName: string, name: string, isRealtimeData: boolean, isRestricted: boolean @@ -47,7 +49,9 @@ export type TelemetryPacket = { export type TelemetryPacketHistory = { packetInfo: { + apId: string id: string, + compoName: string, name: string, isRealtimeData: boolean, isRestricted: boolean @@ -58,9 +62,13 @@ export type TelemetryPacketHistory = { export type TelemetryState = { tlmColor: TelemetryColor, latest: { - [packetName: string]: Telemetry[] + [compoName: string]: { + [packetName: string]: Telemetry[] + } }, history: { - [packetName: string]: TelemetryHistory[] + [apid: string]: { + [packetName: string]: TelemetryHistory[] + } } } diff --git a/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts b/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts index 86473b6..0106ac5 100644 --- a/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts +++ b/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts @@ -7,7 +7,9 @@ export type TelemetryViewIndex = FileIndex & { dataLength: string, ylabelMin: string, ylabelMax: string, - packetId: string + packetId: string, + apId: string, + compoName: string } export type ViewBlockInfo = { diff --git a/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts b/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts index 16cae09..871e92c 100644 --- a/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts +++ b/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts @@ -50,8 +50,8 @@ export const joinOperation = (operation: Operation) => { if (resTlms.status == 200) { const jsonTlms = await resTlms.json(); const tlmPackets = jsonTlms.data as TelemetryPacket[]; - const packetIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_packet", name: packet.packetInfo.name, filePath: "", packetId: packet.packetInfo.id, type: "packet", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); - const graphIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_graph", name: packet.packetInfo.name, filePath: "", packetId: packet.packetInfo.id, type: "graph", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); + const packetIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_packet", name: packet.packetInfo.name, filePath: "", apId: packet.packetInfo.apId, packetId: packet.packetInfo.id, compoName: packet.packetInfo.compoName, type: "packet", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); + const graphIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_graph", name: packet.packetInfo.name, filePath: "", apId: packet.packetInfo.apId, packetId: packet.packetInfo.id, compoName: packet.packetInfo.compoName, type: "graph", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); const viewIndexes = [...packetIndexes, ...graphIndexes]; dispatch(fetchViewIndexesAction(viewIndexes)); diff --git a/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts b/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts index 378199a..49f3b2f 100644 --- a/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts +++ b/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts @@ -22,7 +22,10 @@ export const TelemetriesReducer = (state = initialState.tlms, action: Actions) = const tlmPackets = action.payload; var tlms = state.latest; tlmPackets.forEach(tlmPacket => { - tlms[tlmPacket.packetInfo.name] = tlmPacket.telemetries; + if (tlms[tlmPacket.packetInfo.compoName] == undefined) { + tlms[tlmPacket.packetInfo.compoName] = {}; + } + tlms[tlmPacket.packetInfo.compoName][tlmPacket.packetInfo.name] = tlmPacket.telemetries; }) return { ...state, @@ -31,7 +34,17 @@ export const TelemetriesReducer = (state = initialState.tlms, action: Actions) = case Actions.UPDATE_TELEMETRY_HISTORY: const tlmPacketHistories = action.payload; - const tlmHistories = tlmPacketHistories.reduce((list, tlmPacketHistory) => ({ ...list, [tlmPacketHistory.packetInfo.name]: tlmPacketHistory.telemetryHistories }), {}) + let tlmHistories = state.history; + tlmPacketHistories.forEach(tlmPacketHistory => { + if (tlmHistories[tlmPacketHistory.packetInfo.compoName] == undefined) { + tlmHistories[tlmPacketHistory.packetInfo.compoName] = {}; + } + tlmHistories[tlmPacketHistory.packetInfo.compoName][tlmPacketHistory.packetInfo.name] = tlmPacketHistory.telemetryHistories; + }, {}) + // const tlmHistories = tlmPacketHistories.reduce((list, tlmPacketHistory) => ( + // { [tlmPacketHistory.packetInfo.compoName]: { ...list, [tlmPacketHistory.packetInfo.name]: tlmPacketHistory.telemetryHistories } } + // ), {}) + // const tlmHistories = tlmPacketHistories.reduce((list, tlmPacketHistory) => ({ ...list, [tlmPacketHistory.packetInfo.name]: tlmPacketHistory.telemetryHistories }), {}) return { ...state, history: tlmHistories @@ -42,8 +55,14 @@ export const TelemetriesReducer = (state = initialState.tlms, action: Actions) = let tlmHstrs = state.history; if (latestTlms.length != 0){ latestTlms.forEach(tlmPacket => { - if(tlmPacket.telemetries[0].telemetryValue.time != null) { - tlmHstrs[tlmPacket.packetInfo.name].forEach((element, index) => { + if (tlmPacket.telemetries[0].telemetryValue.time != null) { + if (tlmHstrs[tlmPacket.packetInfo.compoName] == undefined) { + tlmHstrs[tlmPacket.packetInfo.compoName] = {}; + tlmHstrs[tlmPacket.packetInfo.compoName][tlmPacket.packetInfo.name] = []; + } else if (tlmHstrs[tlmPacket.packetInfo.compoName][tlmPacket.packetInfo.name] == undefined) { + tlmHstrs[tlmPacket.packetInfo.compoName][tlmPacket.packetInfo.name] = []; + } + tlmHstrs[tlmPacket.packetInfo.compoName][tlmPacket.packetInfo.name].forEach((element, index) => { element.telemetryValues.push(tlmPacket.telemetries[index].telemetryValue); }) } From 23f1407041edac1ac65b02f9ade056f88fe5a3ef Mon Sep 17 00:00:00 2001 From: Tomoki Date: Thu, 23 Feb 2023 22:57:25 +0900 Subject: [PATCH 09/19] add sample config.json --- aspnetapp/WINGS/TlmCmd/ISSL_COMMON/tlmdb/config.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 aspnetapp/WINGS/TlmCmd/ISSL_COMMON/tlmdb/config.json diff --git a/aspnetapp/WINGS/TlmCmd/ISSL_COMMON/tlmdb/config.json b/aspnetapp/WINGS/TlmCmd/ISSL_COMMON/tlmdb/config.json new file mode 100644 index 0000000..faf1bd4 --- /dev/null +++ b/aspnetapp/WINGS/TlmCmd/ISSL_COMMON/tlmdb/config.json @@ -0,0 +1,3 @@ +[ + { "apId": "0x123", "compoName": "ISSL_OBC"} +] \ No newline at end of file From a80e386900abce027bc4b14088e5c3fc3aae6a82 Mon Sep 17 00:00:00 2001 From: Tomoki Date: Fri, 24 Feb 2023 10:50:29 +0900 Subject: [PATCH 10/19] remove unnecessary comment --- aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts b/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts index 49f3b2f..11616c5 100644 --- a/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts +++ b/aspnetapp/WINGS/ClientApp/src/redux/telemetries/reducers.ts @@ -41,10 +41,6 @@ export const TelemetriesReducer = (state = initialState.tlms, action: Actions) = } tlmHistories[tlmPacketHistory.packetInfo.compoName][tlmPacketHistory.packetInfo.name] = tlmPacketHistory.telemetryHistories; }, {}) - // const tlmHistories = tlmPacketHistories.reduce((list, tlmPacketHistory) => ( - // { [tlmPacketHistory.packetInfo.compoName]: { ...list, [tlmPacketHistory.packetInfo.name]: tlmPacketHistory.telemetryHistories } } - // ), {}) - // const tlmHistories = tlmPacketHistories.reduce((list, tlmPacketHistory) => ({ ...list, [tlmPacketHistory.packetInfo.name]: tlmPacketHistory.telemetryHistories }), {}) return { ...state, history: tlmHistories From f0adae4c2b548f62099ea331c5da86d535de5108 Mon Sep 17 00:00:00 2001 From: Tomoki Date: Sat, 25 Mar 2023 16:48:10 +0900 Subject: [PATCH 11/19] rename apid into tlmApid --- .../WINGS/ClientApp/src/models/Telemetry.ts | 6 ++-- .../ClientApp/src/models/TelemetryView.ts | 2 +- .../src/redux/operations/operations.ts | 4 +-- aspnetapp/WINGS/Data/TelemetryDbRepository.cs | 2 +- aspnetapp/WINGS/Models/Telemetry.cs | 2 +- aspnetapp/WINGS/Models/TlmCmdFileConfig.cs | 2 +- .../Abstracts/TmPacketAnalyzerBase.cs | 12 ++++---- .../ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs | 10 +++---- .../UserDefined/MOBC/MobcTmPacketAnalyzer.cs | 30 +++++++++---------- .../SecondaryObcTmPacketAnalyzer.cs | 10 +++---- .../TlmCmd/ISSL_COMMON/tlmdb/config.json | 2 +- aspnetapp/WINGS/TlmCmd/OBC/tlmdb/config.json | 4 +++ .../TlmCmd/SECONDARY_OBC/tlmdb/config.json | 3 ++ 13 files changed, 48 insertions(+), 41 deletions(-) create mode 100644 aspnetapp/WINGS/TlmCmd/OBC/tlmdb/config.json create mode 100644 aspnetapp/WINGS/TlmCmd/SECONDARY_OBC/tlmdb/config.json diff --git a/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts b/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts index c02ca79..ead0a20 100644 --- a/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts +++ b/aspnetapp/WINGS/ClientApp/src/models/Telemetry.ts @@ -37,7 +37,7 @@ export type TelemetryValue = { export type TelemetryPacket = { packetInfo: { - apId: string, + tlmApid: string, id: string, compoName: string, name: string, @@ -49,7 +49,7 @@ export type TelemetryPacket = { export type TelemetryPacketHistory = { packetInfo: { - apId: string + tlmApid: string id: string, compoName: string, name: string, @@ -67,7 +67,7 @@ export type TelemetryState = { } }, history: { - [apid: string]: { + [compoName: string]: { [packetName: string]: TelemetryHistory[] } } diff --git a/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts b/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts index 0106ac5..6ac5a9e 100644 --- a/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts +++ b/aspnetapp/WINGS/ClientApp/src/models/TelemetryView.ts @@ -8,7 +8,7 @@ export type TelemetryViewIndex = FileIndex & { ylabelMin: string, ylabelMax: string, packetId: string, - apId: string, + tlmApid: string, compoName: string } diff --git a/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts b/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts index 871e92c..41b64ef 100644 --- a/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts +++ b/aspnetapp/WINGS/ClientApp/src/redux/operations/operations.ts @@ -50,8 +50,8 @@ export const joinOperation = (operation: Operation) => { if (resTlms.status == 200) { const jsonTlms = await resTlms.json(); const tlmPackets = jsonTlms.data as TelemetryPacket[]; - const packetIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_packet", name: packet.packetInfo.name, filePath: "", apId: packet.packetInfo.apId, packetId: packet.packetInfo.id, compoName: packet.packetInfo.compoName, type: "packet", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); - const graphIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_graph", name: packet.packetInfo.name, filePath: "", apId: packet.packetInfo.apId, packetId: packet.packetInfo.id, compoName: packet.packetInfo.compoName, type: "graph", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); + const packetIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_packet", name: packet.packetInfo.name, filePath: "", tlmApid: packet.packetInfo.tlmApid, packetId: packet.packetInfo.id, compoName: packet.packetInfo.compoName, type: "packet", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); + const graphIndexes: TelemetryViewIndex[] = tlmPackets.map(packet => ({ id: packet.packetInfo.name + "_graph", name: packet.packetInfo.name, filePath: "", tlmApid: packet.packetInfo.tlmApid, packetId: packet.packetInfo.id, compoName: packet.packetInfo.compoName, type: "graph", selectedTelemetries: [], dataType: "Default", dataLength: "500", ylabelMin: "", ylabelMax: "" })); const viewIndexes = [...packetIndexes, ...graphIndexes]; dispatch(fetchViewIndexesAction(viewIndexes)); diff --git a/aspnetapp/WINGS/Data/TelemetryDbRepository.cs b/aspnetapp/WINGS/Data/TelemetryDbRepository.cs index c5f84de..ed33b4e 100644 --- a/aspnetapp/WINGS/Data/TelemetryDbRepository.cs +++ b/aspnetapp/WINGS/Data/TelemetryDbRepository.cs @@ -82,7 +82,7 @@ private async Task LoadFileAsync(TlmCmdFileLocation location, T packetName = packetName.Substring(packetName.IndexOf("_TLM_DB_") + 8); } var packetInfo = new PacketInfo(){ - ApId = tlmConfig.ApId, + TlmApid = tlmConfig.TlmApid, Id = packetId, CompoName = tlmConfig.CompoName, Name = packetName, diff --git a/aspnetapp/WINGS/Models/Telemetry.cs b/aspnetapp/WINGS/Models/Telemetry.cs index 696d441..3095952 100644 --- a/aspnetapp/WINGS/Models/Telemetry.cs +++ b/aspnetapp/WINGS/Models/Telemetry.cs @@ -17,7 +17,7 @@ public class TelemetryPacket } public class PacketInfo { - public string ApId { get; set; } + public string TlmApid { get; set; } public string Id { get; set; } public string CompoName { get; set; } public string Name { get; set; } diff --git a/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs b/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs index 62e6b30..36c9930 100644 --- a/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs +++ b/aspnetapp/WINGS/Models/TlmCmdFileConfig.cs @@ -14,7 +14,7 @@ public class TlmCmdFileLocationInfo public class TlmConfigurationInfo { - public string ApId { get; set; } + public string TlmApid { get; set; } public string CompoName { get; set; } } diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs index 32c3ac8..a3bc1c9 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/Abstracts/TmPacketAnalyzerBase.cs @@ -23,25 +23,25 @@ public virtual void RemoveOperation(string opid) { } - protected async Task SetTelemetryListValuesAsync(List dataList, List apIdList, List packetIdList, List realtimeFlagList, List TIList, List prevTelemetry) + protected async Task SetTelemetryListValuesAsync(List dataList, List tlmApidList, List packetIdList, List realtimeFlagList, List TIList, List prevTelemetry) { for (int i = 0; i < dataList.Count(); i++) { - await SetTelemetryValuesAsync(dataList[i], apIdList[i], packetIdList[i], realtimeFlagList[i], TIList[i], prevTelemetry); + await SetTelemetryValuesAsync(dataList[i], tlmApidList[i], packetIdList[i], realtimeFlagList[i], TIList[i], prevTelemetry); } return true; } - protected async Task SetTelemetryValuesAsync(TmPacketData data, string apId, string packetId, bool isRealtimeData, UInt32 TI, List prevTelemetry) + protected async Task SetTelemetryValuesAsync(TmPacketData data, string tlmApid, string packetId, bool isRealtimeData, UInt32 TI, List prevTelemetry) { var opid = data.Opid; - var target = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.ApId == apId) && (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == isRealtimeData)); + var target = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.TlmApid == tlmApid) && (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == isRealtimeData)); if (target == null && isRealtimeData == false) // case for the first time of recordtlm packet { - var targetRealtime = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == true)); + var targetRealtime = prevTelemetry.FirstOrDefault(packet => (packet.PacketInfo.TlmApid == tlmApid) && (packet.PacketInfo.Id == packetId) && (packet.PacketInfo.IsRealtimeData == true)); var packetInfo = new PacketInfo(){ - ApId = targetRealtime.PacketInfo.ApId, + TlmApid = targetRealtime.PacketInfo.TlmApid, Id = targetRealtime.PacketInfo.Id, CompoName = targetRealtime.PacketInfo.CompoName, Name = targetRealtime.PacketInfo.Name, diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs index cba9166..70e95f9 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/ISSL_COMMON/IsslCommonTmPacketAnalyzer.cs @@ -14,14 +14,14 @@ public IsslCommonTmPacketAnalyzer(ITelemetryLogRepository logRepository) : base( public override async Task AnalyzePacketAsync(TmPacketData data, List prevTelemetry) { - var apId = GetApId(data.TmPacket); + var tlmApid = GetTlmApid(data.TmPacket); var packetId = GetPacketId(data.TmPacket); var isRealtimeData = true; UInt32 TI = 0; - return await SetTelemetryValuesAsync(data, apId, packetId, isRealtimeData, TI, prevTelemetry); + return await SetTelemetryValuesAsync(data, tlmApid, packetId, isRealtimeData, TI, prevTelemetry); } - private UInt16 CombiteBytes(byte[] bytes, int pos) + private UInt16 CombineBytes(byte[] bytes, int pos) { UInt16 byte1 = (UInt16)bytes[pos]; UInt16 byte2 = (UInt16)bytes[pos + 1]; @@ -29,11 +29,11 @@ private UInt16 CombiteBytes(byte[] bytes, int pos) return (UInt16)(byte1s + byte2); } - private string GetApId(byte[] packet) + private string GetTlmApid(byte[] packet) { //packet : CCSDS Packet int pos = 0; - return string.Format("0x{0:x3}", CombiteBytes(packet, pos) & 0b_0000_0111_1111_1111); + return string.Format("0x{0:x3}", CombineBytes(packet, pos) & 0b_0000_0111_1111_1111); } public override byte GetCmdWindow() diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs index 91e485a..d97306c 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/MOBC/MobcTmPacketAnalyzer.cs @@ -49,7 +49,7 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List(); - var apIdList = new List(); + var tlmApidList = new List(); var packetIdList = new List(); var realtimeFlagList = new List(); var TIList = new List(); @@ -70,7 +70,7 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List()); } - var ccsdsPriHeaderPointer = CombiteBytes(data.TmPacket, tfPriHeaderLen) & 0b_0000_0111_1111_1111; + var ccsdsPriHeaderPointer = CombineBytes(data.TmPacket, tfPriHeaderLen) & 0b_0000_0111_1111_1111; if (ccsdsPriHeaderPointer == 0b_0111_1111_1111) { //No CCSDS Packet starts in this Transferframe @@ -79,10 +79,10 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List AnalyzePacketAsync(TmPacketData data, List AnalyzePacketAsync(TmPacketData data, List AnalyzePacketAsync(TmPacketData data, List AnalyzePacketAsync(TmPacketData data, List ccsdsdataList, List apIdList, List packetIdList, List realtimeFlagList, List TIList) + private void AddTelemetryList(string opid, byte[] ccsdstmPacket, List ccsdsdataList, List tlmApidList, List packetIdList, List realtimeFlagList, List TIList) { ccsdsdataList.Add(new TmPacketData{ Opid = opid, TmPacket = ccsdstmPacket }); - apIdList.Add(GetApId(ccsdstmPacket)); + tlmApidList.Add(GetTlmApid(ccsdstmPacket)); packetIdList.Add(GetPacketId(ccsdstmPacket)); realtimeFlagList.Add(GetRealTimeFlag(ccsdstmPacket)); TIList.Add(GetTI(ccsdstmPacket)); } - private UInt16 CombiteBytes(byte[] bytes, int pos) + private UInt16 CombineBytes(byte[] bytes, int pos) { UInt16 byte1 = (UInt16)bytes[pos]; UInt16 byte2 = (UInt16)bytes[pos + 1]; UInt16 byte1s = (UInt16)(byte1 << 8); return (UInt16)(byte1s + byte2); } - private UInt16 CombiteBytesGetLen(byte[] bytes, int pos) + private UInt16 CombineBytesGetLen(byte[] bytes, int pos) { UInt16 byte1 = (UInt16)bytes[pos]; UInt16 byte2 = (UInt16)bytes[pos + 1]; @@ -196,11 +196,11 @@ private UInt16 CombiteBytesGetLen(byte[] bytes, int pos) return (UInt16)(byte1s + byte2 + 1); //起算 } - private string GetApId(byte[] packet) + private string GetTlmApid(byte[] packet) { //packet : CCSDS Packet int pos = 0; - return string.Format("0x{0:x3}", CombiteBytes(packet, pos) & 0b_0000_0111_1111_1111); + return string.Format("0x{0:x3}", CombineBytes(packet, pos) & 0b_0000_0111_1111_1111); } private string GetPacketId(byte[] packet) diff --git a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs index f657bbd..59b201e 100644 --- a/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs +++ b/aspnetapp/WINGS/Services/TMTC/Processor/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketAnalyzer.cs @@ -23,14 +23,14 @@ public override async Task AnalyzePacketAsync(TmPacketData data, List Date: Sat, 25 Mar 2023 16:53:01 +0900 Subject: [PATCH 12/19] add display --- .../telemetry/view_display/GraphTabPanel.tsx | 22 +++++++++++++++++ .../telemetry/view_display/PacketTabPanel.tsx | 24 +++++++++---------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx index 803bbbe..c92c49e 100644 --- a/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx +++ b/aspnetapp/WINGS/ClientApp/src/components/telemetry/view_display/GraphTabPanel.tsx @@ -62,6 +62,19 @@ const useStyles = makeStyles((theme: Theme) => width: "3cm", fontSize: "10pt" }, + title: { + color: '#ffff00' + }, + titleWithSpace: { + color: 'white', + fontSize: 12, + paddingRight: 20 + }, + titleWithOutSpace: { + color: 'white', + fontSize: 12, + paddingRight: 20 + } })); export interface GraphTabPanelProps { @@ -235,6 +248,15 @@ const GraphTabPanel = (props: GraphTabPanelProps) => { return (
+
+ Name : {tab.name} +
+
+ Apid : 0x{Number(tab.tlmApid).toString(16)} +
+
+ Packet Id : 0x{Number(tab.packetId).toString(16)} +
width: '80%', maxHeight: 435, }, - packetId: { + title: { + color: '#ffff00' + }, + titleWithSpace: { color: 'white', fontSize: 12, paddingRight: 20 }, - packetIdTitle: { - color: '#ffff00' - }, - tabName: { + titleWithOutSpace: { color: 'white', fontSize: 12, paddingRight: 20 - }, - tabNameTitle: { - color: '#ffff00' } })); @@ -216,11 +213,14 @@ const PacketTabPanel = (props: PacketTabPanelProps) => { -
- Name : {tab.name} +
+ Name : {tab.name} +
+
+ Apid : 0x{Number(tab.tlmApid).toString(16)}
-
- Packet Id : 0x{Number(tab.packetId).toString(16)} +
+ Packet Id : 0x{Number(tab.packetId).toString(16)}