koteswara rao
Member
- Joined
- Feb 1, 2022
- Messages
- 12
- Programming Experience
- 3-5
Hi,
When i writing log in to text file its was not in the real time. Please Help in this task..
Writing thread
When i writing log in to text file its was not in the real time. Please Help in this task..
Writing thread
C#:
private void WriteEnggLog(string CompleteData)
{
try
{
extraData2 += CompleteData;
CompleteData = extraData2.Replace(startsWith3, "|");
string[] packts = CompleteData.Split('|');
extraData2 = string.Empty;
for (int rg = 0; rg < packts.Length; rg++)
{
if (packts[rg] != "")
{
string Data = ( startsWith3 + packts[rg]);
if (Data.Length == 1588)
{
strHexaLog = FCU_Helper.HextoAscII(Data.Substring(0, 8)).PadRight(10);
strEngLog += Littleendinfor2BytesForRev(FCU_Helper.HextoAscII((Data.Substring(0, 8))))+"\t";
double xtime = Convert.ToDouble(FCU_Helper.Hex2Dec(Data.Substring(8, 4)));
strHexaLog += "0x" + Data.Substring(8, 4).PadRight(10);
xtime = xtime * 0.01;
strEngLog += OutAddzerostostring(xtime.ToString(),8).ToString()+"\t";
for (int i = 1; i < 259; i++)
{
try
{
string TextBoxValue = string.Empty;
string OutVal = string.Empty;
{
string[] positionForLog = paramPosForLog[i].Split(',');
string val1 = (Data.Substring(Convert.ToInt32(positionForLog[0]), Convert.ToInt32(positionForLog[1])));
strHexaLog += "0x" + val1.PadRight(10);
TextBoxValue = Expression3(val1, FarmulaparametersForLog[i]);
if ((i >= 240))
{
OutVal = (Convert.ToDecimal(TextBoxValue).ToString());
}
else
{
if (FlagofIEEEForLog[i] == "IEEENOTOK")
{
if (i < 240)
{
if (TextBoxes3[i] == "GCUAzAchieved" ||
TextBoxes3[i] == "GCUElAchieved" ||
TextBoxes3[i] == "GCUAzCommanded" ||
TextBoxes3[i] == "GCUElCommanded")
{
OutVal = ValidationforSineWaveForGCU2(FCU_Helper.Hex2Dec(val1).ToString());
OutVal = OutAddzerostostring(OutVal, 8);
}
else if (TextBoxes3[i] == "ACUCommandedMotor1" ||
TextBoxes3[i] == "ACUCommandedMotor2" ||
TextBoxes3[i] == "ACUCommandedMotor3" ||
TextBoxes3[i] == "ACUCommandedMotor4" ||
TextBoxes3[i] == "ACUAchievedMotor1" ||
TextBoxes3[i] == "ACUAchievedMotor2" ||
TextBoxes3[i] == "ACUAchievedMotor3" ||
TextBoxes3[i] == "ACUAchievedMotor4")
{
OutVal = ValidationforSineWaveForACU2(FCU_Helper.Hex2Dec(val1).ToString());
OutVal = OutAddzerostostring(OutVal, 8);
}
else
{
OutVal = Math.Round(Convert.ToDecimal(TextBoxValue), 8).ToString();
OutVal = OutAddzerostostring(OutVal, 8);
}
}
else
{
OutVal = Math.Round(Convert.ToDecimal(TextBoxValue), 8).ToString();
OutVal = OutAddzerostostring(OutVal, 8);
}
}
else
{
// OutVal = Math.Round(FCU_Helper.validateHextoFloat(val1), 4).ToString();
OutVal = Math.Round(FCU_Helper.validateHextoFloat(val1), 8).ToString();
OutVal = OutAddzerostostring(OutVal, 8);
}
}
strEngLog += OutVal + "\t";
}
}
catch (Exception exG)
{
}
}
string hexafpath = FcuMain.FCULogsPath + logfile1 + "/HexaLog";
string hexpath = hexafpath + "\\" + logfile1 + "_" + DateTime.Now.ToString("ddMMMyyyy_HH") + "_" + Quniquefile2 + ".txt";
using (StreamWriter stream = new FileInfo(hexpath).AppendText())
{
stream.WriteLine(strHexaLog);
} string engfpath = FcuMain.FCULogsPath + logfile1 + "/EngLog";
string engpath = engfpath + "\\" + logfile1 + "_" + DateTime.Now.ToString("ddMMMyyyy_HH") + "_" + Quniquefile2 + ".txt";
using (StreamWriter stream = new FileInfo(engpath).AppendText())
{
if (headingCounter == 0)
{
string Configuration = HeaddingsConfigData + FCU_Health.FCUHealthLog + Environment.NewLine + FCU_IMUconfig.ImuConfigLog + Environment.NewLine + FCU_ConfigVN100ADIS.VN100ADISLog + Environment.NewLine + FCU_ConfigVN100ADIS.MissileConfigLog;
stream.WriteLine(Configuration + "\n");
string[] headings = TestFile_Eng.Split('$');
stream.WriteLine("Header " + headings[0].Replace(",", " ".PadRight(4)));
}
stream.Write(strEngLog);
}
strEngLog = "";
headingCounter++;
}
else
{
extraData2 = Data;
}
}
strEngLog += Environment.NewLine;
}
}
catch (Exception ex)
{
}
}
Last edited by a moderator: