122 lines
4.0 KiB
C#
122 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.IO;
|
|
using SOH.JianYan.YiQi.Base;
|
|
|
|
namespace SOH.JianYan.DEC_BW500
|
|
{
|
|
public partial class BW500 : SOH.JianYan.YiQi.Base.baseMain
|
|
{
|
|
public BW500()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
protected override void decoder()
|
|
{
|
|
base.decoder();
|
|
string decodefile = Application.StartupPath + "\\raw\\data.txt";
|
|
if (System.IO.File.Exists(decodefile))
|
|
{
|
|
int a = 0;
|
|
string data = "";
|
|
aa:
|
|
try
|
|
{
|
|
FileStream fs = new FileStream(decodefile, FileMode.Open, FileAccess.Read, FileShare.None);
|
|
StreamReader sr = new StreamReader(fs);
|
|
data = sr.ReadToEnd();
|
|
sr.Close();
|
|
sr.Dispose();
|
|
|
|
}
|
|
catch
|
|
{
|
|
a++;
|
|
if (a > 11)
|
|
goto aa;
|
|
}
|
|
if(data.EndsWith("\u000d\u000a\u0003"))
|
|
{
|
|
File.Delete(decodefile);
|
|
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
string[] sjs = data.Split(ETX);
|
|
|
|
foreach (string sj in sjs)
|
|
{
|
|
string[] items = sj.Split("\r\n".ToCharArray());
|
|
string sampleno = "";
|
|
DateTime sampletime = DateTime.Now;
|
|
foreach (string item in items)
|
|
{
|
|
if (item.StartsWith("\u0002"))
|
|
continue;
|
|
if (item.StartsWith(" No. :"))
|
|
{
|
|
sampleno = item.Replace(" No. :", "");
|
|
continue;
|
|
}
|
|
if (item.StartsWith(" Date:"))
|
|
{
|
|
string date = item.Replace(" Date:", "");
|
|
sampletime = DateTime.Parse(date);
|
|
continue;
|
|
}
|
|
if (item == "")
|
|
continue;
|
|
// LEU - 0 cells/u
|
|
if (item.Length == "*BIL 3+ 100 umol/l".Length)
|
|
{
|
|
string tdh = item.Substring(0, 4);
|
|
string z1 = item.Substring(4, 3);
|
|
string z2 = item.Substring(7, " 100".Length);
|
|
if (Lis_result.canmodify(_yqbm, sampletime.Date, sampleno))
|
|
{
|
|
Lis_result.addresult(sampletime.Date, _yqbm, sampleno, tdh.Remove(0, 1).Trim(), z1.Trim()==""? z2.Trim():z1.Trim());
|
|
}
|
|
}
|
|
|
|
}
|
|
Lis_result.calcsample(_yqbm, sampletime.Date, sampleno);
|
|
}
|
|
}
|
|
}
|
|
|
|
string _yqbm = "";
|
|
private void BW500_Load(object sender, EventArgs e)
|
|
{
|
|
System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(Application.StartupPath + "\\local.ext");
|
|
|
|
if (conf.AppSettings.Settings.AllKeys.Contains("yqbm"))
|
|
{
|
|
_yqbm = conf.AppSettings.Settings["yqbm"].Value;
|
|
}
|
|
if (System.IO.File.Exists(Application.StartupPath + "\\SOH.OnLine.exe"))
|
|
{
|
|
System.Diagnostics.Process p = System.Diagnostics.Process.Start(Application.StartupPath + "\\SOH.OnLine.exe");
|
|
Program.ps = p;
|
|
}
|
|
|
|
}
|
|
|
|
private void BW500_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
if(!Program.ps.HasExited)
|
|
Program.ps.Kill();
|
|
|
|
}
|
|
}
|
|
}
|