This package provides translation of the SPD file and also provides grouping of the data.
$ dotnet add package SPDFileTranslatorPlease note that to handle the exceptions, you will need to add a global exception handler (or similar) to your project and prefereably implement ILogger to track any exceptions.
string inputFile = "C:\\35860011.SPD";
SPDData spdData = new SPDTranslatorImplementation(inputFile);
await spdData.ReadSPDDataAsync();
This will return the translated data and you can do what you need to with it.
The groupings are for use in charting and reporting, they are not saved in any way. Saving groupings can be achieved in your application.
Please take note of the Enum below.
public enum SPDReadingValuesGroupingTypeEnum
{
Minutes = 1,
FifteenMinutes = 2,
ThirtyMinutes = 3,
Hourly = 4,
Daily = 5,
}
From the SPDData model get the serial number as follows:
int serialNumber = spdData.SPDHeaderValues.SPDSerialNumber;
Use the required enum value and the device serial number to create the required grouping.
SPDDataGroupingsImplementation grouping = new SPDDataGroupingsImplementation(spdData.ReadingValues, serialNumber);
var group = grouping.GroupCurrentByPhaseByTime(SPDReadingValuesGroupingTypeEnum.Minutes);
To save the data you can save it as XML, JSON or CSV.
This will write the SPDData values and will not write the groupings.
WARNING! The XML and JSON files can be very large up to 200MB so it is reccomended these are processed once as the memeory usage is significant.
The invalid character check has been turned off for the XML file creation. There is a check in code to remove non XML characters, but there maybe some charaters such as null terminations which are not caught, so please check for additional invalid characters in your processing.
string outputRoot = "C:\\SPCData";
SPDTranslatorImplementationSaveFiles saveFiles = new SPDTranslatorImplementationSaveFiles(spdData, outputRoot);
await saveFiles.SaveCsvDataAsync();
await saveFiles.SaveJsonDataAsyn();
await saveFiles.SaveXMLDataAsync();