LL18-25062501;修改得辉达反馈保存ini文件压差和泄漏量为0,没有sn问题
This commit is contained in:
@@ -43,8 +43,9 @@ namespace C_Windows_1
|
||||
private double delaytime;
|
||||
private float X, Y;
|
||||
|
||||
private string DLeakPressure = "0";
|
||||
private string DLeak = "0";
|
||||
private string DLeakPressure = "0"; //测试压力
|
||||
private string DLeak = "0"; //泄漏量
|
||||
private string DPressureDiff = "0"; //压差
|
||||
public OperateResult operateResult21;
|
||||
public OperateResult operateResult22;
|
||||
public OperateResult<bool> operateResult23;
|
||||
@@ -62,7 +63,8 @@ namespace C_Windows_1
|
||||
|
||||
public static string tablename;
|
||||
string CODE;
|
||||
public bool ChkINI;
|
||||
public bool checkINI; //选中ini导出
|
||||
public bool checkTxt; //选中txt导出
|
||||
|
||||
public Form1()
|
||||
{
|
||||
@@ -349,8 +351,7 @@ namespace C_Windows_1
|
||||
ReadData[9] = 0;
|
||||
operateResult21 = Modbusread(25, 6, ReadData);
|
||||
Tlight.Text = "";
|
||||
CODE= Code.Text = PreCode1.Text;
|
||||
PreCode1.Text="";
|
||||
CODE= Code.Text;
|
||||
if (operateResult21.IsSuccess == true)
|
||||
{
|
||||
int aaa;
|
||||
@@ -381,18 +382,24 @@ namespace C_Windows_1
|
||||
Modbusread(25, 12, ReadData);
|
||||
Modbusread(37, 1, ReadData);
|
||||
Modbusread(38, 12, ReadData);
|
||||
Modbusread(161, 2, ReadData);
|
||||
//test(ReadData);
|
||||
int ba = progressBar2.Value + 2;
|
||||
if (ba >= progressBar2.Maximum)
|
||||
ba = progressBar2.Maximum;
|
||||
progressBar2.Value = ba;
|
||||
MachineStatus.Text = "测试中";
|
||||
|
||||
//if (ReadData[8] != 0 && (ReadData[9] == 1 || ReadData[9] == 2))//当仪器状态位不为0且有结果时
|
||||
//{
|
||||
// workstation = (int)yiqi.finish;
|
||||
// //return workstation;
|
||||
//}
|
||||
MachineStatus.Text = "测试中";
|
||||
|
||||
//泄漏量
|
||||
if (ReadData[19] !=0 || ReadData[18] != 0)
|
||||
{
|
||||
DLeak = TwoUInt16ToFloat(ReadData[19], ReadData[18]).ToString("f1");
|
||||
}
|
||||
//压差
|
||||
if (ReadData[161] != 0 || ReadData[162] != 0)
|
||||
{
|
||||
DPressureDiff = TwoUInt16ToFloat(ReadData[162], ReadData[161]).ToString("f3");
|
||||
}
|
||||
if (ReadData[8] == 0)
|
||||
{
|
||||
System.Threading.Thread.Sleep(200);
|
||||
@@ -405,6 +412,8 @@ namespace C_Windows_1
|
||||
{
|
||||
progressBar2.Value = 0;
|
||||
workstation = (int)yiqi.standby;
|
||||
DLeak = "0.0";
|
||||
DPressureDiff = "0.000";
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -419,7 +428,6 @@ namespace C_Windows_1
|
||||
break;
|
||||
|
||||
case (int)yiqi.finish:
|
||||
Modbusread(161, 2, ReadData); // 压差
|
||||
Modbusread(16, 4, ReadData);
|
||||
progressBar2.Value = progressBar2.Maximum;
|
||||
DataGridView1.Invoke(new System.Action(Display));
|
||||
@@ -821,7 +829,6 @@ namespace C_Windows_1
|
||||
//CH1文本框读取的压力和泄漏量
|
||||
LeakPressure.Text = TwoUInt16ToFloat(ReadData[17], ReadData[16]).ToString("f3");
|
||||
Leak.Text = TwoUInt16ToFloat(ReadData[19], ReadData[18]).ToString("f1");
|
||||
|
||||
break;
|
||||
|
||||
case (int)yiqi.finish:
|
||||
@@ -2041,124 +2048,12 @@ namespace C_Windows_1
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
/*
|
||||
private void AddTXT()
|
||||
/// <summary>
|
||||
/// 添加配置文件
|
||||
/// </summary>
|
||||
/// <param name="iType">0:INI; 1:TXT</param>
|
||||
private void AddINI(int iType = 0)
|
||||
{
|
||||
//string fileName;
|
||||
//string file = DateTime.Now.ToString("yyyyMMdd");
|
||||
//if (path.Text == "")
|
||||
//{
|
||||
// fileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\leaktest.txt";
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// fileName = path.Text + "\\" + file + ".txt";
|
||||
//}
|
||||
|
||||
|
||||
// 文件路径
|
||||
//string basePath = string.IsNullOrEmpty(path.Text) ? Environment.GetFolderPath(Environment.SpecialFolder.Desktop) : path.Text; //桌面
|
||||
string basePath = string.IsNullOrEmpty(path.Text) ? Application.StartupPath : path.Text;
|
||||
|
||||
// 目标路径下创建MES子目录
|
||||
string logDirectory = Path.Combine(basePath, "MES");
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
|
||||
// 文件名
|
||||
string fileName = $"{CODE}_{DateTime.Now:yyMMdd_HHmmss}.txt";
|
||||
string fullPath = Path.Combine(logDirectory, fileName);
|
||||
|
||||
string str1 = "时间 " + DateTime.Now +
|
||||
" 条形码 " + CODE +
|
||||
" 充气时间 " + ReadData[25] / 10.0 + "s" +
|
||||
" 平衡时间 " + ReadData[26] / 10.0 + "s" +
|
||||
" 检测时间 " + ReadData[27] / 10.0 + "s" +
|
||||
" 排气时间 " + ReadData[28] / 10.0 + "s" +
|
||||
" 充气压力上限 " + TwoUInt16ToFloat(ReadData[33], ReadData[32]).ToString() + PressureUnit.Text +
|
||||
" 充气压力下限 " + TwoUInt16ToFloat(ReadData[47], ReadData[46]).ToString() + PressureUnit.Text +
|
||||
//" 大漏压差上限 " + ReadData[36] + LeakUnit.Text +
|
||||
//" 大漏压差下限 " + (Digitalconversion(ReadData[37])).ToString() + LeakUnit.Text +
|
||||
" 泄漏量上限 " + TwoUInt16ToFloat(ReadData[39], ReadData[38]).ToString() + LeakUnit.Text +
|
||||
" 泄漏量下限 " + TwoUInt16ToFloat(ReadData[45], ReadData[44]).ToString() + LeakUnit.Text +
|
||||
" 测试结果 " + Tlight.Text +
|
||||
" 测试压力 " + TwoUInt16ToFloat(ReadData[17], ReadData[16]).ToString() +
|
||||
" 压力单位 " + PressureUnit.Text +
|
||||
" 泄漏量 " + DLeak +
|
||||
" 泄漏量单位 " + LeakUnit.Text + " \n";
|
||||
System.IO.File.AppendAllText(fullPath, str1);
|
||||
}
|
||||
*/
|
||||
|
||||
//将数据写入TXT
|
||||
private void AddTXT()
|
||||
{
|
||||
//Console.WriteLine("AddTXT()");
|
||||
//CODE = "N2479000099"; // 测试用SN
|
||||
//ReadData[25] = 2;
|
||||
//ReadData[26] = 2;
|
||||
//ReadData[27] = 2;
|
||||
//ReadData[28] = 2;
|
||||
|
||||
try
|
||||
{
|
||||
// 文件路径
|
||||
// string basePath = string.IsNullOrEmpty(path.Text) ? Environment.GetFolderPath(Environment.SpecialFolder.Desktop) : path.Text; //桌面
|
||||
string basePath = string.IsNullOrEmpty(path.Text) ? Application.StartupPath : path.Text;
|
||||
|
||||
// 目标路径下创建MES子目录
|
||||
string logDirectory = Path.Combine(basePath, "MES");
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
|
||||
// 文件名
|
||||
string fileName = $"{CODE}_{DateTime.Now:yyMMdd_HHmmss}.txt";
|
||||
string fullPath = Path.Combine(logDirectory, fileName);
|
||||
|
||||
string testResult = Tlight.Text;
|
||||
if (string.IsNullOrEmpty(testResult.Trim()))
|
||||
{
|
||||
testResult = "fail";
|
||||
}
|
||||
|
||||
// INI内容
|
||||
StringBuilder iniContent = new StringBuilder();
|
||||
iniContent.AppendLine("[Info]");
|
||||
iniContent.AppendLine($"sn={CODE} ");//#SN号码
|
||||
iniContent.AppendLine($"type= ");//#当前工站名称
|
||||
//iniContent.AppendLine("wifi_mac= ");//#wifimac
|
||||
//iniContent.AppendLine("bt_mac= "); //#btmac
|
||||
string testDetails =
|
||||
$"检测压力={TwoUInt16ToFloat(ReadData[17], ReadData[16]).ToString()};" +
|
||||
$"充气时间={ReadData[25] / 10.0 + "s"};" +
|
||||
$"平衡时间={ReadData[26] / 10.0 + "s"};" +
|
||||
$"检测时间={ReadData[27] / 10.0 + "s"};" +
|
||||
$"排气时间={ReadData[28] / 10.0 + "s"};" +
|
||||
$"当前压差={TwoUInt16ToFloat(ReadData[162], ReadData[161]).ToString()};" +
|
||||
$"泄露量={DLeak};"; // TwoUInt16ToFloat(ReadData[19], ReadData[18]).ToString("f1")
|
||||
iniContent.AppendLine($"message={testDetails}");//#测试项目与结果记录
|
||||
float totalTime = (ReadData[25] + ReadData[26] + ReadData[27] + ReadData[28]) / 10.0f;
|
||||
iniContent.AppendLine($"totaltime={totalTime}"); //#测试所用时间
|
||||
iniContent.AppendLine($"starttime={DateTime.Now:yyyy/MM/dd HH:mm:ss}");// #开始时间
|
||||
iniContent.AppendLine($"endtime={DateTime.Now.AddSeconds(totalTime):yyyy/MM/dd HH:mm:ss} ");//#结束时间
|
||||
iniContent.AppendLine($"result={testResult}");//#Pass or Fail
|
||||
|
||||
// 7. 写入文件
|
||||
File.WriteAllText(fullPath, iniContent.ToString(), Encoding.UTF8);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"生成日志失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void AddINI()
|
||||
{
|
||||
//Console.WriteLine("AddINI()");
|
||||
//CODE = "N2479000099"; // 测试用SN
|
||||
//ReadData[25] = 2;
|
||||
//ReadData[26] = 2;
|
||||
//ReadData[27] = 2;
|
||||
//ReadData[28] = 2;
|
||||
|
||||
try
|
||||
{
|
||||
// 文件路径
|
||||
@@ -2169,7 +2064,8 @@ namespace C_Windows_1
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
|
||||
// 文件名
|
||||
string fileName = $"{CODE}_{DateTime.Now:yyMMdd_HHmmss}.ini";
|
||||
string fileName = $"{CODE}_{DateTime.Now:yyMMdd_HHmmss}.";
|
||||
fileName += iType == 0 ? "ini" : "txt";
|
||||
string fullPath = Path.Combine(logDirectory, fileName);
|
||||
|
||||
string testResult = Tlight.Text;
|
||||
@@ -2191,7 +2087,7 @@ namespace C_Windows_1
|
||||
$"平衡时间={ReadData[26] / 10.0 + "s"};" +
|
||||
$"检测时间={ReadData[27] / 10.0 + "s"};" +
|
||||
$"排气时间={ReadData[28] / 10.0 + "s"};" +
|
||||
$"当前压差={TwoUInt16ToFloat(ReadData[162], ReadData[161]).ToString()};" +
|
||||
$"当前压差={DPressureDiff};" +
|
||||
$"泄露量={DLeak};"; // TwoUInt16ToFloat(ReadData[19], ReadData[18]).ToString("f1")
|
||||
iniContent.AppendLine($"message={testDetails}");//#测试项目与结果记录
|
||||
float totalTime = (ReadData[25] + ReadData[26] + ReadData[27] + ReadData[28]) / 10.0f;
|
||||
@@ -2373,20 +2269,15 @@ namespace C_Windows_1
|
||||
//}
|
||||
//Console.WriteLine("ChkTXT.Checked:" + ChkTXT.Checked);
|
||||
//Console.WriteLine("ChkINI:" + ChkINI);
|
||||
if (ChkTXT.Checked)
|
||||
|
||||
if (checkTxt)
|
||||
{
|
||||
AddTXT();
|
||||
AddINI(1);
|
||||
}
|
||||
|
||||
if (ChkINI)
|
||||
if(checkINI)
|
||||
{
|
||||
AddINI();
|
||||
|
||||
// 测试失败不允许生成log文件
|
||||
//if (Tlight.Text.Contains("OK"))
|
||||
//{
|
||||
// AddINI();
|
||||
//}
|
||||
AddINI(0);
|
||||
}
|
||||
//if (ChkSql.Checked)
|
||||
//{
|
||||
@@ -2747,20 +2638,20 @@ namespace C_Windows_1
|
||||
|
||||
if (regName.GetValue("txt") is null)
|
||||
{
|
||||
ChkTXT.Checked = false;
|
||||
checkTxt = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChkTXT.Checked = Convert.ToBoolean(regName.GetValue("txt").ToString());
|
||||
checkTxt = Convert.ToBoolean(regName.GetValue("txt").ToString());
|
||||
}
|
||||
|
||||
if (regName.GetValue("ini") is null)
|
||||
{
|
||||
ChkINI = false;
|
||||
checkINI = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChkINI = Convert.ToBoolean(regName.GetValue("ini").ToString());
|
||||
checkINI = Convert.ToBoolean(regName.GetValue("ini").ToString());
|
||||
}
|
||||
|
||||
if (regName.GetValue("sql") is null)
|
||||
@@ -3125,21 +3016,6 @@ namespace C_Windows_1
|
||||
bool flag3 = this.Code.TextLength == int.Parse(this.CodeLength.Text) && this.checkBox1.Checked;
|
||||
if (flag3)
|
||||
{
|
||||
//InserPatch(Code.Text, 1);
|
||||
//if (checkBox2.Checked)
|
||||
//{
|
||||
// int obj = await InMes(1);
|
||||
// if (obj == 1)
|
||||
// {
|
||||
// this.textBox3.Text = "入站 OK";
|
||||
// this.textBox3.BackColor = Color.Green;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.textBox3.Text = "入站 OK";
|
||||
// this.textBox3.BackColor = Color.Green;
|
||||
// }
|
||||
//}
|
||||
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
BarcodeInfo.InsertBarcodeData(time, Code.Text, "", "", "", "", "", "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user