You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple smaller issues were found at the conversion of *.dfq-files:
Sometimes there are double empty lines in the dfq files.
At the end of file, there has to be two empty lines to cover the measurement data
In all my dfq-files, there were no separation between the K10*-addresses and the K20*-addresses. The separation of line blocks has to be made by comparing the previous value with a string match.
I fixed the issues in the code below. You might integrate this solution if you want to.
public void Convert(string dfqFilePath)
{
if (string.IsNullOrEmpty(dfqFilePath))
throw new ArgumentException("dfqFilePath");
Parts = new List<Part>();
Characteristics = new List<Characteristic>();
_currentPart = null;
var dfqFile = File.ReadAllLines(dfqFilePath);
var sectionBlock = new List<List<string>>();
var lineBlock = new List<string>();
Boolean addToLineblock = false;
int counter = 1;
//Create Blocks from file, then process the blocks
for (int i=0; i<dfqFile.Length; i++)
{
String previousLine = "";
String currentLine = dfqFile[i];
String nextLine = "";
if (i>0)
{
previousLine = dfqFile[i - 1];
}
if (i<dfqFile.Length-1)
{
nextLine = dfqFile[i + 1];
}
//Set the separator
//1. Empty lines
//2. K10* to K20 if there is no line break
//Create lineblock
//Console.WriteLine("Create text blocks.");
//=== Special text splitter ===//
//Check if there is a special splitter
Boolean textSplitActiveStart = false;
if (previousLine.StartsWith("K10") && currentLine.StartsWith("K20"))
{
textSplitActiveStart = true;
Console.WriteLine("Special text split start K10*->K20*");
}
//====================================//
//Stop line block
if (string.IsNullOrEmpty(currentLine) || textSplitActiveStart == true || string.IsNullOrEmpty(nextLine))
{
sectionBlock.Add(new List<String>(lineBlock));
lineBlock.Clear();
addToLineblock = false;
Console.WriteLine("End line block at line: " + counter + ">" + currentLine);
}
//Start line block
//Startpart is at start/run, previousline was empty or split K1*/K2 was active
if (string.IsNullOrEmpty(currentLine)==false && (counter==1 || string.IsNullOrEmpty(previousLine)==true || textSplitActiveStart==true))
{
addToLineblock = true;
Console.WriteLine("Start new lineblock at line: " + counter + ">" + currentLine);
}
//Add line if block is open
if (addToLineblock==true)
{
lineBlock.Add(currentLine);
Console.WriteLine("Added line to block. Line: " + counter + ">" + currentLine);
}
counter++;
}
Console.WriteLine("Created " + sectionBlock.Count() + " section blocks.");
Console.WriteLine("Process each section block.");
foreach (var block in sectionBlock)
{
if (block.Count()>0)
{
ProcessBlock(block);
}
}
Console.WriteLine("Conversion finished");
}
The text was updated successfully, but these errors were encountered:
Multiple smaller issues were found at the conversion of *.dfq-files:
I fixed the issues in the code below. You might integrate this solution if you want to.
public void Convert(string dfqFilePath)
{
if (string.IsNullOrEmpty(dfqFilePath))
throw new ArgumentException("dfqFilePath");
The text was updated successfully, but these errors were encountered: