1476 lines
58 KiB
C#
1476 lines
58 KiB
C#
|
|
//using BLECom;
|
|||
|
|
using JJServer;
|
|||
|
|
using log4net;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
using Newtonsoft.Json.Linq;
|
|||
|
|
using JJMediSys.Properties;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Net;
|
|||
|
|
using System.Net.Sockets;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Runtime.InteropServices;
|
|||
|
|
using System.ServiceProcess;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using System.Xml;
|
|||
|
|
using Windows.Devices.Bluetooth;
|
|||
|
|
using static JJMediSys.AlertForm;
|
|||
|
|
using JJMediSys.cs;
|
|||
|
|
using System.Data.Common;
|
|||
|
|
|
|||
|
|
namespace JJMediSys
|
|||
|
|
{
|
|||
|
|
public partial class SystemSet : Form
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public string[] ports;
|
|||
|
|
public string SelectPort = "";
|
|||
|
|
|
|||
|
|
|
|||
|
|
public static ILog logger = LogManager.GetLogger("WebLogger");
|
|||
|
|
|
|||
|
|
System.Timers.Timer timerCheckStatus = new System.Timers.Timer();
|
|||
|
|
public System.Timers.Timer timerCheckTask = new System.Timers.Timer();
|
|||
|
|
System.Timers.Timer timerGetDevStatus = new System.Timers.Timer();
|
|||
|
|
static Socket socketserver = null;
|
|||
|
|
public static TubeLabelTool mTubeLabelTool;
|
|||
|
|
public static int RecpImageSize = 13440;// 29736; //13440
|
|||
|
|
public static object locker = new object();
|
|||
|
|
public static object lockerForCheckTask = new object();
|
|||
|
|
|
|||
|
|
|
|||
|
|
public DataTable BoxTable;
|
|||
|
|
public static SystemSet systemSet;
|
|||
|
|
//public static BLECom.JJBLE jJBLE = new BLECom.JJBLE();
|
|||
|
|
|
|||
|
|
public MyServer myServer = new MyServer();
|
|||
|
|
|
|||
|
|
public static string MessageShowInfo = "";
|
|||
|
|
|
|||
|
|
public string TbPargs = ""; //贴标参数 参数1;参数2
|
|||
|
|
ShowMessage showMessage = new ShowMessage();
|
|||
|
|
SetKZM setKZM;
|
|||
|
|
|
|||
|
|
public SocketClient socketClient;
|
|||
|
|
public static bool IsDispensing = false;
|
|||
|
|
public static bool CancelDispensing = false;
|
|||
|
|
|
|||
|
|
public static Point DispenseWindowLocation = new Point(9999,9999);
|
|||
|
|
|
|||
|
|
public bool AutoClose = false; //出管窗口自动关机
|
|||
|
|
public static int TimeDelay = 8;
|
|||
|
|
public static bool UseBle = false;
|
|||
|
|
public static int BoxTubeMaxCount = 12;
|
|||
|
|
public bool ExtBle = false; //外部蓝牙
|
|||
|
|
public string ExtBleAddr = "";//外部蓝牙地址
|
|||
|
|
|
|||
|
|
public struct StatusDetail
|
|||
|
|
{
|
|||
|
|
public int TubeCar { get; set; } //0正常 1忙 2故障
|
|||
|
|
public int MainPrinter { get; set; } //0正常 1忙 2故障
|
|||
|
|
public int SecPrinter { get; set; } //0正常 1忙 2故障
|
|||
|
|
public int Stick { get; set; } //0正常 1忙 2故障
|
|||
|
|
|
|||
|
|
|
|||
|
|
public int MainPrintPaper { get; set; } //0正常 1将近
|
|||
|
|
public int SecPrintPaper { get; set; } //0正常 1将近
|
|||
|
|
|
|||
|
|
public int MainPrintHeard { get; set; } //0正常 1故障
|
|||
|
|
public int SecPrintHeard { get; set; } //0正常 1故障
|
|||
|
|
|
|||
|
|
public string TubeCarErrorCode { get; set; }
|
|||
|
|
public string MainPrinterErrorCode { get; set; }
|
|||
|
|
public string SecPrinterErrorCode { get; set; }
|
|||
|
|
public string StickErrorCode { get; set; }
|
|||
|
|
public byte [] TubeStat { get; set; }
|
|||
|
|
|
|||
|
|
public byte[] BackUpSensorStat { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public StatusDetail statusDetail;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* public struct LabInfo
|
|||
|
|
{
|
|||
|
|
public string Patient_Name { get; set; }
|
|||
|
|
public string Patient_ID { get; set; }
|
|||
|
|
public string Patient_Sex { get; set; }
|
|||
|
|
public string Patinet_Age { get; set; }
|
|||
|
|
public string Item { get; set; }
|
|||
|
|
public string ItemClass { get; set; }
|
|||
|
|
public string TestTube { get; set; }
|
|||
|
|
public string Urgent { get; set; }
|
|||
|
|
public string Barcode { get; set; }
|
|||
|
|
public string Time1 { get; set; }
|
|||
|
|
public string Time2 { get; set; }
|
|||
|
|
public string ReportTime { get; set; }
|
|||
|
|
public string location { get; set; }
|
|||
|
|
public string Dispense { get; set; }
|
|||
|
|
public string PrintRecp { get; set; }
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
|
|||
|
|
public bool IsIpAddress(string input)
|
|||
|
|
{
|
|||
|
|
IPAddress address;
|
|||
|
|
return IPAddress.TryParse(input, out address);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public SystemSet()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
timerCheckTask.Elapsed += new System.Timers.ElapsedEventHandler(CheckTask);
|
|||
|
|
timerCheckTask.Interval = 1000;//每5秒执行一次
|
|||
|
|
timerCheckTask.Enabled = true;
|
|||
|
|
|
|||
|
|
timerCheckStatus.Elapsed += new System.Timers.ElapsedEventHandler(CheckDevStatus);
|
|||
|
|
timerCheckStatus.Interval = 5000;//每5秒执行一次
|
|||
|
|
timerCheckStatus.Enabled = true;
|
|||
|
|
mTubeLabelTool = new TubeLabelTool();
|
|||
|
|
mTubeLabelTool.Open();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CheckDevStatus(object sender, System.Timers.ElapsedEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (mTubeLabelTool.comTool.isOpen()&& mTubeLabelTool.IsDevFree && !IsDispensing)
|
|||
|
|
{
|
|||
|
|
timerCheckStatus.Enabled = false;
|
|||
|
|
if(MainForm.ifWindowOpen("系统参数设置"))
|
|||
|
|
{
|
|||
|
|
GetDeviceStatus();
|
|||
|
|
FreshLight();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GetDeviceStatusNoUI();
|
|||
|
|
}
|
|||
|
|
timerCheckStatus.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void Form1_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int x = (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2;
|
|||
|
|
int y = (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2;
|
|||
|
|
this.Location = new Point(x, y);
|
|||
|
|
|
|||
|
|
string ShowComLog = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='ShowComLog']");
|
|||
|
|
if (ShowComLog == "0")
|
|||
|
|
LogCtrol.Text = "打开串口日志";
|
|||
|
|
else
|
|||
|
|
LogCtrol.Text = "关闭串口日志";
|
|||
|
|
//socketPort = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='ServicePort']");
|
|||
|
|
ports = System.IO.Ports.SerialPort.GetPortNames();
|
|||
|
|
SelectPort = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='ComPort']");
|
|||
|
|
foreach (var str in ports)
|
|||
|
|
{
|
|||
|
|
comboPort.Items.Add(str);
|
|||
|
|
if (SelectPort == str)
|
|||
|
|
comboPort.SelectedItem = str;
|
|||
|
|
}
|
|||
|
|
SgxxParse();
|
|||
|
|
|
|||
|
|
string AutoCloseStr = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='AutoClose']");
|
|||
|
|
string AutoCloseTime = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='AutoCloseTime']");
|
|||
|
|
if (AutoCloseStr.Equals("1"))
|
|||
|
|
AutoClose = true;
|
|||
|
|
TimeDelay = int.Parse(AutoCloseTime);
|
|||
|
|
string UseBlestr = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='UseBLE']");
|
|||
|
|
if (UseBlestr.Equals("1"))
|
|||
|
|
UseBle = true;
|
|||
|
|
|
|||
|
|
string ExtBlestr = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='ExtBLE']");
|
|||
|
|
if (ExtBlestr.Equals("1"))
|
|||
|
|
ExtBle = true;
|
|||
|
|
ExtBleAddr = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='BLEServer']");
|
|||
|
|
|
|||
|
|
string BoxTubeMaxCountstr = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='BoxMaxTubeCount']");
|
|||
|
|
BoxTubeMaxCount = int.Parse(BoxTubeMaxCountstr);
|
|||
|
|
systemSet = this;
|
|||
|
|
statusDetail.TubeStat = new byte[7]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|||
|
|
statusDetail.BackUpSensorStat = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|||
|
|
myServer.Init();
|
|||
|
|
PublicStatic.EventMgr.initDB("EventManager.dict", "CREATE TABLE EVENTINFOLIST (ID INTEGER PRIMARY KEY, Msg TEXT, Details TEXT,Time TEXT)");
|
|||
|
|
ParseDBConnectStr();
|
|||
|
|
TextWinName.Text = Login.nurseDeskInfo.WindowName;
|
|||
|
|
Thread.Sleep(2000);
|
|||
|
|
myServer.Start();
|
|||
|
|
/*if(UseBle)
|
|||
|
|
{
|
|||
|
|
Thread threadBLETask = new Thread(DoBleTask);// 处理蓝牙任务
|
|||
|
|
threadBLETask.Start();
|
|||
|
|
}
|
|||
|
|
if(ExtBle)
|
|||
|
|
{
|
|||
|
|
if(!IsIpAddress(ExtBleAddr))
|
|||
|
|
{
|
|||
|
|
logger.Info($"外部蓝牙地址错误:{ExtBleAddr}");
|
|||
|
|
AlertForm.ShowAlert($"外部蓝牙地址错误:{ExtBleAddr}", AlertType.Error, 3);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
socketClient = new SocketClient(ExtBleAddr,8080);
|
|||
|
|
if (!socketClient.Connect())
|
|||
|
|
{
|
|||
|
|
logger.Info($"连接外部蓝牙服务失败:{ExtBleAddr}");
|
|||
|
|
AlertForm.ShowAlert($"连接外部蓝牙服务失败:{ExtBleAddr}", AlertType.Error, 3);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/*
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public struct BleTask
|
|||
|
|
{
|
|||
|
|
public BluetoothLEDevice TargDevice { get; set; }
|
|||
|
|
public string CodeStr { get; set; }
|
|||
|
|
public byte[] ImageDataBlack { get; set; }
|
|||
|
|
public byte[] ImageDataRed { get; set; }
|
|||
|
|
public string MACstr { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static Queue<BleTask> bleTaskQueue = new Queue<BleTask>();
|
|||
|
|
|
|||
|
|
public void DoBleTask()
|
|||
|
|
{
|
|||
|
|
while(true)
|
|||
|
|
{
|
|||
|
|
if(bleTaskQueue.Count>0)
|
|||
|
|
{
|
|||
|
|
BleTask bleTask = bleTaskQueue.Dequeue();
|
|||
|
|
Thread threadSendBle = new Thread(SendBleData);// 发送蓝牙数据
|
|||
|
|
threadSendBle.Start(bleTask);
|
|||
|
|
}
|
|||
|
|
Thread.Sleep(500);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public async void SendBleData( object obj)
|
|||
|
|
{
|
|||
|
|
logger.Info("进入SendBleData线程");
|
|||
|
|
BleTask bleTask = (BleTask) obj;
|
|||
|
|
int ReTryTimes = 5;//重发次数
|
|||
|
|
bleTask.ImageDataBlack = new byte[4000];
|
|||
|
|
bleTask.ImageDataRed = new byte[4000];
|
|||
|
|
byte[] ImageDataBlack = new byte[4000];
|
|||
|
|
byte[] ImageDataRed = new byte[4000];
|
|||
|
|
Array.Clear(ImageDataBlack, 0, ImageDataBlack.Length);
|
|||
|
|
Array.Clear(ImageDataRed, 0, ImageDataRed.Length);
|
|||
|
|
RecpCreate recpCreate = new RecpCreate();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (ExtBle)
|
|||
|
|
{
|
|||
|
|
logger.Info("使用外部蓝牙");
|
|||
|
|
if (!socketClient.Status)
|
|||
|
|
{
|
|||
|
|
if(!socketClient.Connect())
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("外部蓝牙服务未连接", AlertType.Success, 3);
|
|||
|
|
});
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
recpCreate.CreateBLEImage(bleTask.CodeStr, ref ImageDataBlack, ref ImageDataRed);
|
|||
|
|
Buffer.BlockCopy(ImageDataBlack, 0, bleTask.ImageDataBlack, 0, ImageDataBlack.Length);
|
|||
|
|
Buffer.BlockCopy(ImageDataRed, 0, bleTask.ImageDataRed, 0, ImageDataRed.Length);
|
|||
|
|
string SendStr = "S" + bleTask.MACstr + BytesToHexString(bleTask.ImageDataBlack) + BytesToHexString(bleTask.ImageDataRed) + "T";
|
|||
|
|
if(!socketClient.SendData(SendStr))
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("发送蓝牙数据到外部服务失败", AlertType.Success, 3);
|
|||
|
|
});
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BLECom.JJBLE mjJBLE = new BLECom.JJBLE();
|
|||
|
|
mjJBLE.SetCurDevices(bleTask.TargDevice);
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
JJBLE.BLEConnectionResult bleResult = await mjJBLE.GetGattServices();
|
|||
|
|
logger.Info("mjJBLE.GetGattServices = " + bleResult);
|
|||
|
|
if (bleResult != JJBLE.BLEConnectionResult.Success)
|
|||
|
|
{
|
|||
|
|
bleResult = await mjJBLE.GetGattServices();
|
|||
|
|
logger.Info("mjJBLE.GetGattServices Again = " + bleResult);
|
|||
|
|
}
|
|||
|
|
if (bleResult == JJBLE.BLEConnectionResult.Success)
|
|||
|
|
{
|
|||
|
|
byte[] Ack = new Byte[1] { 0x05 };
|
|||
|
|
await mjJBLE.WriteNoAnswer(Ack);
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
byte[] ReadVer = new Byte[5] { 0x02, 0x02, 0xC5, 0x01, 0x03 };
|
|||
|
|
JJBLE.BLESendAndRecvResult resultVer = await mjJBLE.Write(ReadVer, ReadVer[2]);
|
|||
|
|
if(resultVer== JJBLE.BLESendAndRecvResult.Success) //解析电量 电量低时设置显示标志
|
|||
|
|
{
|
|||
|
|
logger.Info("bettery");
|
|||
|
|
int bettery = (int)(mjJBLE.VersionInfo[6]) * 255 +(int) (mjJBLE.VersionInfo[7]);
|
|||
|
|
logger.Info("bettery="+ bettery.ToString());
|
|||
|
|
if (bettery<290)
|
|||
|
|
{
|
|||
|
|
bleTask.CodeStr = bleTask.CodeStr + "@TB16235105020030|L^L";
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
logger.Info("bleTask.CodeStr=" + bleTask.CodeStr);
|
|||
|
|
recpCreate.CreateBLEImage(bleTask.CodeStr, ref ImageDataBlack, ref ImageDataRed);
|
|||
|
|
Buffer.BlockCopy(ImageDataBlack, 0, bleTask.ImageDataBlack, 0, ImageDataBlack.Length);
|
|||
|
|
Buffer.BlockCopy(ImageDataRed, 0, bleTask.ImageDataRed, 0, ImageDataRed.Length);
|
|||
|
|
for (int i = 0; i < 20; i++)
|
|||
|
|
{
|
|||
|
|
byte[] SendData = new byte[206];
|
|||
|
|
SendData[0] = 0x02;
|
|||
|
|
SendData[1] = 0xCB;
|
|||
|
|
SendData[2] = 0xC1;
|
|||
|
|
SendData[3] = (byte)(i);
|
|||
|
|
Buffer.BlockCopy(bleTask.ImageDataBlack, 200 * i, SendData, 4, 200);
|
|||
|
|
byte temp = 0x00;
|
|||
|
|
for (int j = 0; j < SendData.Length - 1; j++)
|
|||
|
|
{
|
|||
|
|
temp = (byte)(temp + SendData[j]);
|
|||
|
|
}
|
|||
|
|
SendData[204] = temp;
|
|||
|
|
SendData[205] = 0x03;
|
|||
|
|
JJBLE.BLESendAndRecvResult bleSendResult = await mjJBLE.Write(SendData,SendData[3]);
|
|||
|
|
if(bleSendResult!= JJBLE.BLESendAndRecvResult.Success&& ReTryTimes>0) //重发
|
|||
|
|
{
|
|||
|
|
i--;
|
|||
|
|
ReTryTimes--;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
for (int i = 0; i < 20; i++)
|
|||
|
|
{
|
|||
|
|
byte[] SendData = new byte[206];
|
|||
|
|
SendData[0] = 0x02;
|
|||
|
|
SendData[1] = 0xCB;
|
|||
|
|
SendData[2] = 0xC2;
|
|||
|
|
SendData[3] = (byte)(i);
|
|||
|
|
Buffer.BlockCopy(bleTask.ImageDataRed, 200 * i, SendData, 4, 200);
|
|||
|
|
byte temp = 0x00;
|
|||
|
|
for (int j = 0; j < SendData.Length - 1; j++)
|
|||
|
|
{
|
|||
|
|
temp = (byte)(temp + SendData[j]);
|
|||
|
|
}
|
|||
|
|
SendData[204] = temp;
|
|||
|
|
SendData[205] = 0x03;
|
|||
|
|
JJBLE.BLESendAndRecvResult bleSendResult = await mjJBLE.Write(SendData, SendData[3]);
|
|||
|
|
if (bleSendResult != JJBLE.BLESendAndRecvResult.Success && ReTryTimes > 0) //重发
|
|||
|
|
{
|
|||
|
|
i--;
|
|||
|
|
ReTryTimes--;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
byte[] Complete = new Byte[5] { 0x02, 0x02, 0xC3, 0xC3, 0x03 };
|
|||
|
|
await mjJBLE.Write(Complete,0xC3);
|
|||
|
|
mjJBLE.Dispose();
|
|||
|
|
logger.Info("关闭蓝牙连接");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool SaveBleInfo(string Addr,bool Extble)
|
|||
|
|
{
|
|||
|
|
ExtBle = Extble;
|
|||
|
|
SetValue("/configuration/appSettings/add[@key='ExtBLE']", Extble?"1":"0");
|
|||
|
|
SetValue("/configuration/appSettings/add[@key='BLEServer']", Addr);
|
|||
|
|
|
|||
|
|
if (socketClient!=null&&socketClient.Status)
|
|||
|
|
{
|
|||
|
|
socketClient.Disconnect();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(Extble)
|
|||
|
|
{
|
|||
|
|
socketClient = new SocketClient(Addr, 8080);
|
|||
|
|
if (!socketClient.Connect())
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("外部蓝牙服务未连接", AlertType.Success, 3);
|
|||
|
|
});
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
static string BytesToHexString(byte[] bytes)
|
|||
|
|
{
|
|||
|
|
StringBuilder sb = new StringBuilder();
|
|||
|
|
foreach (byte b in bytes)
|
|||
|
|
{
|
|||
|
|
sb.AppendFormat("{0:x2}", b);
|
|||
|
|
}
|
|||
|
|
return sb.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public void SgxxParse()
|
|||
|
|
{
|
|||
|
|
string[] Sginfo1 = ConfigFileReader.GetValue("/configuration/GROUP/SGINFO/add[@key='G1']").Split('|');
|
|||
|
|
if (Sginfo1.Length == 6)
|
|||
|
|
{
|
|||
|
|
if (Sginfo1[0] == "1")
|
|||
|
|
SG1InUse.Checked = true;
|
|||
|
|
SG1Name.Text = Sginfo1[4];
|
|||
|
|
SG1Ctrol.Text = Sginfo1[5];
|
|||
|
|
SG1Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
string[] Sginfo2 = ConfigFileReader.GetValue("/configuration/GROUP/SGINFO/add[@key='G2']").Split('|');
|
|||
|
|
if (Sginfo2.Length == 6)
|
|||
|
|
{
|
|||
|
|
if (Sginfo2[0] == "1")
|
|||
|
|
SG2InUse.Checked = true;
|
|||
|
|
SG2Name.Text = Sginfo2[4];
|
|||
|
|
SG2Ctrol.Text = Sginfo2[5];
|
|||
|
|
SG2Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
string[] Sginfo3 = ConfigFileReader.GetValue("/configuration/GROUP/SGINFO/add[@key='G3']").Split('|');
|
|||
|
|
if (Sginfo3.Length == 6)
|
|||
|
|
{
|
|||
|
|
if (Sginfo3[0] == "1")
|
|||
|
|
SG3InUse.Checked = true;
|
|||
|
|
SG3Name.Text = Sginfo3[4];
|
|||
|
|
SG3Ctrol.Text = Sginfo3[5];
|
|||
|
|
SG3Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
string[] Sginfo4 = ConfigFileReader.GetValue("/configuration/GROUP/SGINFO/add[@key='G4']").Split('|');
|
|||
|
|
if (Sginfo4.Length == 6)
|
|||
|
|
{
|
|||
|
|
if (Sginfo4[0] == "1")
|
|||
|
|
SG4InUse.Checked = true;
|
|||
|
|
SG4Name.Text = Sginfo4[4];
|
|||
|
|
SG4Ctrol.Text = Sginfo4[5];
|
|||
|
|
SG4Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
SG4Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
string[] Sginfo5 = ConfigFileReader.GetValue("/configuration/GROUP/SGINFO/add[@key='G5']").Split('|');
|
|||
|
|
if (Sginfo5.Length == 6)
|
|||
|
|
{
|
|||
|
|
if (Sginfo5[0] == "1")
|
|||
|
|
SG5InUse.Checked = true;
|
|||
|
|
SG5Name.Text = Sginfo5[4];
|
|||
|
|
SG5Ctrol.Text = Sginfo5[5];
|
|||
|
|
SG5Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
string[] Sginfo6 = ConfigFileReader.GetValue("/configuration/GROUP/SGINFO/add[@key='G6']").Split('|');
|
|||
|
|
if (Sginfo6.Length == 6)
|
|||
|
|
{
|
|||
|
|
if (Sginfo6[0] == "1")
|
|||
|
|
SG6InUse.Checked = true;
|
|||
|
|
SG6Name.Text = Sginfo6[4];
|
|||
|
|
SG6Ctrol.Text = Sginfo6[5];
|
|||
|
|
SG6Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
string[] Sginfo7 = ConfigFileReader.GetValue("/configuration/GROUP/SGINFO/add[@key='G7']").Split('|');
|
|||
|
|
if (Sginfo7.Length == 6)
|
|||
|
|
{
|
|||
|
|
if (Sginfo7[0] == "1")
|
|||
|
|
SG7InUse.Checked = true;
|
|||
|
|
SG7Name.Text = Sginfo7[4];
|
|||
|
|
SG7Ctrol.Text = Sginfo7[5];
|
|||
|
|
SG7Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void label2_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void bSave1_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
ConfigFileReader.SetValue("/configuration/appSettings/add[@key='ComPort']", comboPort.SelectedItem.ToString());
|
|||
|
|
AlertForm.ShowAlert("保存成功", AlertType.Success, 3);
|
|||
|
|
mTubeLabelTool.Open();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void bSave2_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
string G1str = (SG1InUse.Checked ? "1" : "0") + "|标签1| | |" + SG1Name.Text + "|" + SG1Ctrol.Text;
|
|||
|
|
ConfigFileReader.SetValue("/configuration/GROUP/SGINFO/add[@key='G1']", G1str);
|
|||
|
|
string G2str = (SG2InUse.Checked ? "1" : "0") + "|标签1| | |" + SG2Name.Text + "|" + SG2Ctrol.Text ;
|
|||
|
|
ConfigFileReader.SetValue("/configuration/GROUP/SGINFO/add[@key='G2']", G2str);
|
|||
|
|
string G3str = (SG3InUse.Checked ? "1" : "0") + "|标签1| | |" + SG3Name.Text + "|" + SG3Ctrol.Text ;
|
|||
|
|
ConfigFileReader.SetValue("/configuration/GROUP/SGINFO/add[@key='G3']", G3str);
|
|||
|
|
string G4str = (SG4InUse.Checked ? "1" : "0") + "|标签1| | |" + SG4Name.Text + "|" + SG4Ctrol.Text ;
|
|||
|
|
ConfigFileReader.SetValue("/configuration/GROUP/SGINFO/add[@key='G4']", G4str);
|
|||
|
|
string G5str = (SG5InUse.Checked ? "1" : "0") + "|标签1| | |" + SG5Name.Text + "|" + SG5Ctrol.Text ;
|
|||
|
|
ConfigFileReader.SetValue("/configuration/GROUP/SGINFO/add[@key='G5']", G5str);
|
|||
|
|
string G6str = (SG6InUse.Checked ? "1" : "0") + "|标签1| | |" + SG6Name.Text + "|" + SG6Ctrol.Text ;
|
|||
|
|
ConfigFileReader.SetValue("/configuration/GROUP/SGINFO/add[@key='G6']", G6str);
|
|||
|
|
string G7str = (SG7InUse.Checked ? "1" : "0") + "|标签1| | |" + SG7Name.Text + "|" + SG7Ctrol.Text ;
|
|||
|
|
ConfigFileReader.SetValue("/configuration/GROUP/SGINFO/add[@key='G7']", G7str);
|
|||
|
|
AlertForm.ShowAlert("保存成功", AlertType.Success, 3);
|
|||
|
|
mTubeLabelTool.LoadSginfo();
|
|||
|
|
string[] Arr = mTubeLabelTool.SetSgCtrol().Split('|');
|
|||
|
|
if (Arr[0] != "0")
|
|||
|
|
{
|
|||
|
|
logger.Info("设置试管参数失败");
|
|||
|
|
AlertForm.ShowAlert("设置试管参数失败", AlertType.Error, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
logger.Info("设置试管参数成功");
|
|||
|
|
AlertForm.ShowAlert("设置试管参数成功", AlertType.Success, 3);
|
|||
|
|
ResetLight();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.CloseReason == CloseReason.UserClosing)
|
|||
|
|
{
|
|||
|
|
e.Cancel = true; //取消关闭操作 表现为不关闭窗体
|
|||
|
|
this.Hide();
|
|||
|
|
this.ShowInTaskbar = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private async void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
this.WindowState = FormWindowState.Normal;
|
|||
|
|
this.Activate();
|
|||
|
|
this.Show();
|
|||
|
|
this.ShowInTaskbar = true;
|
|||
|
|
await Task.Run(() =>
|
|||
|
|
{
|
|||
|
|
if (mTubeLabelTool.comTool.isOpen())
|
|||
|
|
{
|
|||
|
|
GetDeviceStatus();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 打开主窗口ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.WindowState = FormWindowState.Normal;
|
|||
|
|
this.Activate();
|
|||
|
|
this.Show();
|
|||
|
|
this.ShowInTaskbar = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if(MessageBox.Show("是否确认退出程序?","退出",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
System.Environment.Exit(0);
|
|||
|
|
this.Dispose();
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Form1_MinimumSizeChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Hide();
|
|||
|
|
this.ShowInTaskbar = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 系统复位ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if(!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("DevReset", null, ref RecvData);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public void SysReset()
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("DevReset", null, ref RecvData);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 小车复位ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("CarReset", null, ref RecvData);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 贴标单元复位ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("LabelReset", null, ref RecvData);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 标签打印机复位ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("RecpReset", null, ref RecvData);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 回执复位ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("Recp2Reset", null, ref RecvData);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 切纸ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("CutRecp", null, ref RecvData);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TimerforSocketStatus_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 更换标签纸ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("ReplaceRecp", null, ref RecvData);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void button1_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
GetDeviceStatus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void GetDeviceStatus()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
textErrorInfo.Text = "";
|
|||
|
|
XGStatus.ForeColor = Color.Red;
|
|||
|
|
P1Status.ForeColor = Color.Red;
|
|||
|
|
TBStatus.ForeColor = Color.Red;
|
|||
|
|
P2Status.ForeColor = Color.Red;
|
|||
|
|
XGError.Text = "";
|
|||
|
|
ZDYError.Text = "";
|
|||
|
|
FDYError.Text = "";
|
|||
|
|
TBError.Text = "";
|
|||
|
|
string retstr = mTubeLabelTool.GetDevStatus();
|
|||
|
|
string[] Arr = retstr.Split('|');
|
|||
|
|
if (Arr.Length == 2 && Arr[0] != "0")
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert(Arr[1], AlertType.Error, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
statusDetail.TubeCar = TransCodemain(mTubeLabelTool.stat.TubeState.ToString("X2"));
|
|||
|
|
statusDetail.MainPrinter = TransCodemain(mTubeLabelTool.stat.PrintState.ToString("X2"));
|
|||
|
|
statusDetail.SecPrinter = TransCodemain(mTubeLabelTool.stat.BackPrintState.ToString("X2"));
|
|||
|
|
statusDetail.Stick = TransCodemain(mTubeLabelTool.stat.StickState.ToString("X2"));
|
|||
|
|
|
|||
|
|
statusDetail.TubeCarErrorCode = mTubeLabelTool.stat.TubeBugCode.ToString("X2");
|
|||
|
|
statusDetail.MainPrinterErrorCode = mTubeLabelTool.stat.PrintBugCode.ToString("X2");
|
|||
|
|
statusDetail.SecPrinterErrorCode = mTubeLabelTool.stat.BackPrintBugCode.ToString("X2");
|
|||
|
|
statusDetail.StickErrorCode = mTubeLabelTool.stat.StickBugCode.ToString("X2");
|
|||
|
|
|
|||
|
|
statusDetail.MainPrintPaper = mTubeLabelTool.stat.PaperLessSensor.ToString("X2") == "00" ? 0 : 1;
|
|||
|
|
statusDetail.SecPrintPaper = mTubeLabelTool.stat.BackPaperLessSensor.ToString("X2") == "00" ? 0 : 1;
|
|||
|
|
|
|||
|
|
statusDetail.MainPrintHeard = mTubeLabelTool.stat.PrintUnitState.ToString("X2") == "01" ? 0 : 2;
|
|||
|
|
statusDetail.SecPrintHeard = mTubeLabelTool.stat.BackPrintUnitState.ToString("X2") == "01" ? 0 : 2;
|
|||
|
|
|
|||
|
|
XGError.Text = statusDetail.TubeCarErrorCode == "00" ? "" : statusDetail.TubeCarErrorCode;
|
|||
|
|
ZDYError.Text = statusDetail.MainPrinterErrorCode == "00" ? "" : statusDetail.MainPrinterErrorCode;
|
|||
|
|
FDYError.Text = statusDetail.SecPrinterErrorCode == "00" ? "" : statusDetail.SecPrinterErrorCode;
|
|||
|
|
TBError.Text = statusDetail.StickErrorCode == "00" ? "" : statusDetail.StickErrorCode;
|
|||
|
|
|
|||
|
|
TransCode(GetMaxValue(statusDetail.TubeCar, (statusDetail.TubeCarErrorCode == "00" ? 0 : 2)), XGStatus);
|
|||
|
|
TransCode(GetMaxValue(statusDetail.MainPrinter, (statusDetail.MainPrinterErrorCode == "00" ? 0 : 2), statusDetail.MainPrintHeard), P1Status);
|
|||
|
|
TransCode(GetMaxValue(statusDetail.Stick, (statusDetail.StickErrorCode == "00" ? 0 : 2)), TBStatus);
|
|||
|
|
TransCode(GetMaxValue(statusDetail.SecPrinter, (statusDetail.SecPrinterErrorCode == "00" ? 0 : 2), statusDetail.SecPrintHeard), P2Status);
|
|||
|
|
TransCode(statusDetail.MainPrintPaper, ZPrintPaper);
|
|||
|
|
TransCode(statusDetail.SecPrintPaper, FPrintPaper);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
string ErrorInfo = "";
|
|||
|
|
if (statusDetail.TubeCar == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "选管单元忙\r\n";
|
|||
|
|
else if (statusDetail.TubeCar == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "选管单元故障\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.MainPrinter == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元忙\r\n";
|
|||
|
|
else if (statusDetail.MainPrinter == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元故障\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.MainPrintHeard == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元,打印头未到位\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.MainPrintPaper == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元,标签纸即将用完\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.SecPrinter == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元忙\r\n";
|
|||
|
|
else if (statusDetail.SecPrinter == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元故障\r\n";
|
|||
|
|
if (statusDetail.SecPrintHeard == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元,打印头未到位\r\n";
|
|||
|
|
if (statusDetail.SecPrintPaper == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元,标签纸即将用完\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.Stick == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "贴标单元忙\r\n";
|
|||
|
|
else if (statusDetail.Stick == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "贴标单元故障\r\n";
|
|||
|
|
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("Car", statusDetail.TubeCarErrorCode);
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("MPrinter", statusDetail.MainPrinterErrorCode);
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("SPrinter", statusDetail.SecPrinterErrorCode);
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("Stick", statusDetail.StickErrorCode);
|
|||
|
|
|
|||
|
|
Buffer.BlockCopy(mTubeLabelTool.stat.PreSaveTubeSensor, 0, statusDetail.TubeStat, 0, 7);
|
|||
|
|
if (statusDetail.TubeStat[0] == 0x00) { ErrorInfo = ErrorInfo + "1号管箱没有预存试管\r\n"; labS1.ForeColor = Color.Red; }
|
|||
|
|
else { labS1.ForeColor = Color.Green; }
|
|||
|
|
if (statusDetail.TubeStat[1] == 0x00) { ErrorInfo = ErrorInfo + "2号管箱没有预存试管\r\n"; labS2.ForeColor = Color.Red; }
|
|||
|
|
else { labS2.ForeColor = Color.Green; }
|
|||
|
|
if (statusDetail.TubeStat[2] == 0x00) { ErrorInfo = ErrorInfo + "3号管箱没有预存试管\r\n"; labS3.ForeColor = Color.Red; }
|
|||
|
|
else { labS3.ForeColor = Color.Green; }
|
|||
|
|
if (statusDetail.TubeStat[3] == 0x00) { ErrorInfo = ErrorInfo + "4号管箱没有预存试管\r\n"; labS4.ForeColor = Color.Red; }
|
|||
|
|
else { labS4.ForeColor = Color.Green; }
|
|||
|
|
if (statusDetail.TubeStat[4] == 0x00) { ErrorInfo = ErrorInfo + "5号管箱没有预存试管\r\n"; labS5.ForeColor = Color.Red; }
|
|||
|
|
else { labS5.ForeColor = Color.Green; }
|
|||
|
|
if (statusDetail.TubeStat[5] == 0x00) { ErrorInfo = ErrorInfo + "6号管箱没有预存试管\r\n"; labS6.ForeColor = Color.Red; }
|
|||
|
|
else { labS6.ForeColor = Color.Green; }
|
|||
|
|
if (statusDetail.TubeStat[6] == 0x00) { ErrorInfo = ErrorInfo + "7号管箱没有预存试管\r\n"; labS7.ForeColor = Color.Red; }
|
|||
|
|
else { labS7.ForeColor = Color.Green; }
|
|||
|
|
|
|||
|
|
// statusDetail.TubeCar = TransCode(mTubeLabelTool.stat.TubeState.ToString("X2"));
|
|||
|
|
|
|||
|
|
Buffer.BlockCopy(mTubeLabelTool.stat.BackUp, 0, statusDetail.BackUpSensorStat, 0, 8);
|
|||
|
|
if (statusDetail.BackUpSensorStat[2] == 0x01)
|
|||
|
|
{
|
|||
|
|
ErrorInfo = ErrorInfo + "试管仓仓门打开\r\n";
|
|||
|
|
}
|
|||
|
|
if (statusDetail.BackUpSensorStat[3] == 0x01)
|
|||
|
|
{
|
|||
|
|
ErrorInfo = ErrorInfo + "标签打印仓门打开\r\n";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
textErrorInfo.Text = ErrorInfo;
|
|||
|
|
if (ShowMessage.ShowStatus && ErrorInfo != MessageShowInfo && ErrorInfo.Length > 0)
|
|||
|
|
{
|
|||
|
|
MessageShowInfo = ErrorInfo;
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.UpdateInfo();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (ErrorInfo != MessageShowInfo)
|
|||
|
|
{
|
|||
|
|
MessageShowInfo = ErrorInfo;
|
|||
|
|
if (MessageShowInfo.Length > 0)
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.ShowScreen();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.HideScreen();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch(Exception e)
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
textErrorInfo.Text = "状态数据异常!";
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void GetDeviceStatusNoUI()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
mTubeLabelTool.GetDevStatus();
|
|||
|
|
statusDetail.TubeCar = TransCodemain(mTubeLabelTool.stat.TubeState.ToString("X2"));
|
|||
|
|
statusDetail.MainPrinter = TransCodemain(mTubeLabelTool.stat.PrintState.ToString("X2"));
|
|||
|
|
statusDetail.SecPrinter = TransCodemain(mTubeLabelTool.stat.BackPrintState.ToString("X2"));
|
|||
|
|
statusDetail.Stick = TransCodemain(mTubeLabelTool.stat.StickState.ToString("X2"));
|
|||
|
|
|
|||
|
|
statusDetail.TubeCarErrorCode = mTubeLabelTool.stat.TubeBugCode.ToString("X2");
|
|||
|
|
statusDetail.MainPrinterErrorCode = mTubeLabelTool.stat.PrintBugCode.ToString("X2");
|
|||
|
|
statusDetail.StickErrorCode = mTubeLabelTool.stat.StickBugCode.ToString("X2");
|
|||
|
|
statusDetail.SecPrinterErrorCode = mTubeLabelTool.stat.BackPrintBugCode.ToString("X2");
|
|||
|
|
|
|||
|
|
statusDetail.MainPrintPaper = mTubeLabelTool.stat.PaperLessSensor.ToString("X2") == "00" ? 0 : 1;
|
|||
|
|
statusDetail.SecPrintPaper = mTubeLabelTool.stat.BackPaperLessSensor.ToString("X2") == "00" ? 0 : 1;
|
|||
|
|
|
|||
|
|
statusDetail.MainPrintHeard = mTubeLabelTool.stat.PrintUnitState.ToString("X2") == "01" ? 0 : 2;
|
|||
|
|
statusDetail.SecPrintHeard = mTubeLabelTool.stat.BackPrintUnitState.ToString("X2") == "01" ? 0 : 2;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
string ErrorInfo = "";
|
|||
|
|
if (statusDetail.TubeCar == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "选管单元忙\r\n";
|
|||
|
|
else if (statusDetail.TubeCar == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "选管单元故障\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.MainPrinter == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元忙\r\n";
|
|||
|
|
else if (statusDetail.MainPrinter == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元故障\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.MainPrintHeard == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元,打印头未到位\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.MainPrintPaper == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "主打印单元,标签纸即将用完\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.SecPrinter == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元忙\r\n";
|
|||
|
|
else if (statusDetail.SecPrinter == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元故障\r\n";
|
|||
|
|
if (statusDetail.SecPrintHeard == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元,打印头未到位\r\n";
|
|||
|
|
if (statusDetail.SecPrintPaper == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "副打印单元,标签纸即将用完\r\n";
|
|||
|
|
|
|||
|
|
if (statusDetail.Stick == 1)
|
|||
|
|
ErrorInfo = ErrorInfo + "贴标单元忙\r\n";
|
|||
|
|
else if (statusDetail.Stick == 2)
|
|||
|
|
ErrorInfo = ErrorInfo + "贴标单元故障\r\n";
|
|||
|
|
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("Car", statusDetail.TubeCarErrorCode);
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("MPrinter", statusDetail.MainPrinterErrorCode);
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("SPrinter", statusDetail.SecPrinterErrorCode);
|
|||
|
|
ErrorInfo = ErrorInfo + TranErrorCode("Stick", statusDetail.StickErrorCode);
|
|||
|
|
|
|||
|
|
Buffer.BlockCopy(mTubeLabelTool.stat.PreSaveTubeSensor, 0, statusDetail.TubeStat, 0, 7);
|
|||
|
|
for (int i = 0; i < 7; i++)
|
|||
|
|
{
|
|||
|
|
if (statusDetail.TubeStat[i] == 0x00)
|
|||
|
|
{
|
|||
|
|
ErrorInfo = ErrorInfo + (i + 1).ToString() + "号管箱没有预存试管\r\n";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Buffer.BlockCopy(mTubeLabelTool.stat.BackUp, 0, statusDetail.BackUpSensorStat, 0, 8);
|
|||
|
|
if(statusDetail.BackUpSensorStat[2] ==0x01)
|
|||
|
|
{
|
|||
|
|
ErrorInfo = ErrorInfo + "试管仓仓门打开\r\n";
|
|||
|
|
}
|
|||
|
|
if (statusDetail.BackUpSensorStat[3] == 0x01)
|
|||
|
|
{
|
|||
|
|
ErrorInfo = ErrorInfo + "标签打印仓门打开\r\n";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (ShowMessage.ShowStatus && ErrorInfo != MessageShowInfo && ErrorInfo.Length > 0)
|
|||
|
|
{
|
|||
|
|
MessageShowInfo = ErrorInfo;
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.UpdateInfo();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (ErrorInfo != MessageShowInfo )
|
|||
|
|
{
|
|||
|
|
MessageShowInfo = ErrorInfo;
|
|||
|
|
if(MessageShowInfo.Length>0)
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.ShowScreen();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.HideScreen();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch(Exception e)
|
|||
|
|
{
|
|||
|
|
if (ShowMessage.ShowStatus && !MessageShowInfo.Equals("状态数据异常!"))
|
|||
|
|
{
|
|||
|
|
MessageShowInfo = "状态数据异常!";
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.UpdateInfo();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (!MessageShowInfo.Equals("状态数据异常!"))
|
|||
|
|
{
|
|||
|
|
MessageShowInfo = "状态数据异常!";
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.ShowScreen();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string TranErrorCode(string Type, string Code)
|
|||
|
|
{
|
|||
|
|
if (Code == "00")
|
|||
|
|
return "";
|
|||
|
|
if (Type == "MPrinter")
|
|||
|
|
{
|
|||
|
|
switch (Code)
|
|||
|
|
{
|
|||
|
|
case "A1":
|
|||
|
|
return "A1:标签纸将尽\r\n";
|
|||
|
|
case "A2":
|
|||
|
|
return "A2:标签纸用完\r\n";
|
|||
|
|
case "E4":
|
|||
|
|
return "E4:没有找到标签\r\n";
|
|||
|
|
case "E5":
|
|||
|
|
return "E5:没有找到标签纸缝隙\r\n";
|
|||
|
|
case "E6":
|
|||
|
|
return "E6:标签太长\r\n";
|
|||
|
|
default:
|
|||
|
|
return Code + ":标签打印机故障\r\n";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (Type == "SPrinter")
|
|||
|
|
{
|
|||
|
|
switch (Code)
|
|||
|
|
{
|
|||
|
|
case "A0":
|
|||
|
|
return "A0:副打印机切刀出错\r\n";
|
|||
|
|
case "A1":
|
|||
|
|
return "A1:副打印机标签传感器出错\r\n";
|
|||
|
|
case "A2":
|
|||
|
|
return "A2:副打印机出口传感器出错\r\n";
|
|||
|
|
case "E0":
|
|||
|
|
return "E0:副打印机复位错误\r\n";
|
|||
|
|
case "E1":
|
|||
|
|
return "E1:没有找到标签\r\n";
|
|||
|
|
case "E2":
|
|||
|
|
return "E2:没有找到标签缝隙\r\n";
|
|||
|
|
default:
|
|||
|
|
return Code + ":副打印机故障\r\n";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (Type == "Car")
|
|||
|
|
{
|
|||
|
|
switch (Code)
|
|||
|
|
{
|
|||
|
|
case "E0":
|
|||
|
|
return "E0:小车电磁铁复位错误\r\n";
|
|||
|
|
case "E1":
|
|||
|
|
return "E1:小车电磁铁弹出错误\r\n";
|
|||
|
|
case "E2":
|
|||
|
|
return "E2:小车检测试管传感器错误\r\n";
|
|||
|
|
case "E3":
|
|||
|
|
return "E3:小车复位错误\r\n";
|
|||
|
|
case "E4":
|
|||
|
|
return "E4:小车往前运行错误\r\n";
|
|||
|
|
case "E5":
|
|||
|
|
return "E5:小车往后运行错误\r\n";
|
|||
|
|
case "E6":
|
|||
|
|
return "E6:小车计数传感器错误\r\n";
|
|||
|
|
case "E7":
|
|||
|
|
return "E7:小车有预存,但是无法进入小车错误\r\n";
|
|||
|
|
case "E8":
|
|||
|
|
return "E8:管箱无法预存错误\r\n";
|
|||
|
|
case "E9":
|
|||
|
|
return "E9:管箱1掉落试管到贴标单元错误\r\n";
|
|||
|
|
default:
|
|||
|
|
return Code + ":选管单元故障\r\n";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (Type == "Stick")
|
|||
|
|
{
|
|||
|
|
switch (Code)
|
|||
|
|
{
|
|||
|
|
case "E0":
|
|||
|
|
return "E0:贴标单元左挡板复位错误\r\n";
|
|||
|
|
case "E1":
|
|||
|
|
return "E1:贴标单元右挡板复位错误\r\n";
|
|||
|
|
case "E2":
|
|||
|
|
return "E2:贴标单元抬升电机复位错误\r\n";
|
|||
|
|
case "E3":
|
|||
|
|
return "E3:贴标单元通信错误\r\n";
|
|||
|
|
case "E7":
|
|||
|
|
return "E7:试管没有掉入贴标单元\r\n";
|
|||
|
|
case "E8":
|
|||
|
|
return "E8:试管没有落入接管盒\r\n";
|
|||
|
|
case "E9":
|
|||
|
|
return "E9:未扫到试管上的条码\r\n";
|
|||
|
|
case "EA":
|
|||
|
|
return "EA:条码识别不一致\r\n";
|
|||
|
|
default:
|
|||
|
|
return Code + ":贴标单元故障\r\n";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int TransCodemain(string Input)
|
|||
|
|
{
|
|||
|
|
switch (Input)
|
|||
|
|
{
|
|||
|
|
case "50":
|
|||
|
|
return 0;
|
|||
|
|
case "52":
|
|||
|
|
return 1;
|
|||
|
|
default:
|
|||
|
|
return 2;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public int GetMaxValue(params int[] numbers)
|
|||
|
|
{
|
|||
|
|
if (numbers == null || numbers.Length == 0)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int max = numbers[0];
|
|||
|
|
for (int i = 1; i < numbers.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (numbers[i] > max)
|
|||
|
|
{
|
|||
|
|
max = numbers[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return max;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void TransCode(int Input, Label lab)
|
|||
|
|
{
|
|||
|
|
switch (Input)
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
lab.ForeColor = Color.Green;
|
|||
|
|
// return 0;
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
lab.ForeColor = Color.Yellow;
|
|||
|
|
// return 1;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
lab.ForeColor = Color.Red;
|
|||
|
|
//return 2;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void LogCtrol_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if(LogCtrol.Text.Equals("打开串口日志"))
|
|||
|
|
{
|
|||
|
|
ConfigFileReader.SetValue("/configuration/appSettings/add[@key='ShowComLog']", "1");
|
|||
|
|
mTubeLabelTool.ShowComLog = "1";
|
|||
|
|
AlertForm.ShowAlert("打开串口日志成功", AlertType.Success, 3);
|
|||
|
|
LogCtrol.Text = "关闭串口日志";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ConfigFileReader.SetValue("/configuration/appSettings/add[@key='ShowComLog']", "0");
|
|||
|
|
AlertForm.ShowAlert("关闭串口日志成功", AlertType.Success, 3);
|
|||
|
|
mTubeLabelTool.ShowComLog = "0";
|
|||
|
|
LogCtrol.Text = "打开串口日志";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 向前发一个标签ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("SendaLabel", null, ref RecvData);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//定时执行事件 ap
|
|||
|
|
private void CheckTask(object sender, System.Timers.ElapsedEventArgs e)
|
|||
|
|
{
|
|||
|
|
timerCheckTask.Enabled = false;
|
|||
|
|
while (true)
|
|||
|
|
{
|
|||
|
|
lock (lockerForCheckTask)
|
|||
|
|
{
|
|||
|
|
if (mTubeLabelTool.comTool.isOpen() && IsDispensing == false)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<PatientDatail> mpatientDatails = new List<PatientDatail>();
|
|||
|
|
myServer.GetTranData(ref mpatientDatails);
|
|||
|
|
if (mpatientDatails != null && mpatientDatails.Count > 0)
|
|||
|
|
{
|
|||
|
|
//IsDispensing = true;
|
|||
|
|
// logger.Info("IsDispensing = true");
|
|||
|
|
Dispensing dispensing = new Dispensing(this,mpatientDatails);
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
dispensing.Show();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//timerCheckTask.Enabled = true;
|
|||
|
|
//logger.Info("IsDispensing = false");
|
|||
|
|
// IsDispensing = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void 固件版本ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!SystemSet.mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
mTubeLabelTool.MechineCtrol("GetVersion", null, ref RecvData);
|
|||
|
|
MessageBox.Show(Encoding.ASCII.GetString(RecvData));
|
|||
|
|
}
|
|||
|
|
private void button2_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
/* byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("Test", null, ref RecvData);*/
|
|||
|
|
|
|||
|
|
//IsDevFree = true;
|
|||
|
|
|
|||
|
|
/* string ErrorInfo = "1号管箱没有预存试管\r\n";
|
|||
|
|
MessageShowInfo = ErrorInfo;
|
|||
|
|
if (MessageShowInfo.Length > 0)
|
|||
|
|
{
|
|||
|
|
this.Invoke((MethodInvoker)delegate
|
|||
|
|
{
|
|||
|
|
showMessage.ShowScreen();
|
|||
|
|
});
|
|||
|
|
}*/
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void 传感器初始化ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("InitSensor", null, ref RecvData);
|
|||
|
|
//IsDevFree = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void bGetKZM_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (setKZM != null && !setKZM.IsDisposed)
|
|||
|
|
setKZM.BringToFront();
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
setKZM = new SetKZM();
|
|||
|
|
// 计算子窗口在主窗口居中的位置
|
|||
|
|
setKZM.StartPosition = FormStartPosition.Manual;
|
|||
|
|
setKZM.Location = new Point(
|
|||
|
|
this.Location.X + (this.Width - setKZM.Width) / 2,
|
|||
|
|
this.Location.Y + (this.Height - setKZM.Height) / 2
|
|||
|
|
);
|
|||
|
|
setKZM.Show();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public DataTable FreshDBData()
|
|||
|
|
{
|
|||
|
|
return myServer.GetHistory();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SingelDispense(PatientDatail patientDatail)
|
|||
|
|
{
|
|||
|
|
string Result = "";
|
|||
|
|
CancelDispensing = false;
|
|||
|
|
lock (locker)
|
|||
|
|
{
|
|||
|
|
IsDispensing = true;
|
|||
|
|
Result = mTubeLabelTool.Dispense(patientDatail);
|
|||
|
|
IsDispensing = false;
|
|||
|
|
}
|
|||
|
|
string[] Arr = Result.Split('|');
|
|||
|
|
if (Arr[0] == "0")
|
|||
|
|
{
|
|||
|
|
logger.Info("发管成功!");
|
|||
|
|
AlertForm.ShowAlert("发管成功", AlertType.Success, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
logger.Info(string.Format("发管失败:{0}", Arr[1]));
|
|||
|
|
AlertForm.ShowAlert(string.Format("发管失败:{0}", Arr[1]), AlertType.Error, 3);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public void MultiDispense(List<PatientDatail> mpatientDatails)
|
|||
|
|
{
|
|||
|
|
myServer.SetTranData(mpatientDatails);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void button9_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
byte[] RecvData = new byte[200];
|
|||
|
|
if (!mTubeLabelTool.IsDevFree)
|
|||
|
|
{
|
|||
|
|
AlertForm.ShowAlert("设备正忙,请稍后", AlertType.Warning, 3);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
mTubeLabelTool.MechineCtrol("GetTbPargs", null, ref RecvData);
|
|||
|
|
string msg = string.Format("{0};{1};{2}", RecvData[3], RecvData[4], RecvData[5]);
|
|||
|
|
MessageBox.Show(msg);
|
|||
|
|
//IsDevFree = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void PClose_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Hide();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void comboPort_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PFreshCom_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
ports = System.IO.Ports.SerialPort.GetPortNames();
|
|||
|
|
SelectPort = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='ComPort']");
|
|||
|
|
comboPort.Items.Clear();
|
|||
|
|
foreach (var str in ports)
|
|||
|
|
{
|
|||
|
|
comboPort.Items.Add(str);
|
|||
|
|
if (SelectPort == str)
|
|||
|
|
comboPort.SelectedItem = str;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void bSaveDB_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
string newDBconnetstr = "server =" + TextDBIP.Text + "; port =" + TextDBPort.Text + "; user id =" + TextDBUser.Text + "; password =" + TextDBPassword.Text + "; database =" + TextDBName.Text + "; Charset = utf8mb4;";
|
|||
|
|
ConfigFileReader.SetValue("/configuration/appSettings/add[@key='Sql']", newDBconnetstr);
|
|||
|
|
DoDBMySql.connectionString = newDBconnetstr;
|
|||
|
|
AlertForm.ShowAlert("保存成功", AlertType.Success, 3);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void ParseDBConnectStr()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string SqlConnect = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='Sql']");
|
|||
|
|
DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
|
|||
|
|
builder.ConnectionString = SqlConnect;
|
|||
|
|
TextDBIP.Text = builder["server"] as string;
|
|||
|
|
TextDBPort.Text = builder["port"] as string;
|
|||
|
|
TextDBName.Text = builder["database"] as string;
|
|||
|
|
TextDBUser.Text = builder["user id"] as string;
|
|||
|
|
TextDBPassword.Text = builder["password"] as string;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void groupBox1_Enter(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SgxxFresh_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
FreshLight();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void FreshLight()
|
|||
|
|
{
|
|||
|
|
int i = 0;
|
|||
|
|
foreach (var t in mTubeLabelTool.listSgSetting)
|
|||
|
|
{
|
|||
|
|
i++;
|
|||
|
|
if (t.LJErr)
|
|||
|
|
{
|
|||
|
|
SetLight(i);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void ResetLight()
|
|||
|
|
{
|
|||
|
|
SG1Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
SG2Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
SG3Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
SG4Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
SG5Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
SG6Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
SG7Light.State = Sunny.UI.UILightState.On;
|
|||
|
|
}
|
|||
|
|
private void SetLight(int No)
|
|||
|
|
{
|
|||
|
|
switch(No)
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
SG1Light.State = Sunny.UI.UILightState.Off;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
SG2Light.State = Sunny.UI.UILightState.Off;
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
SG3Light.State = Sunny.UI.UILightState.Off;
|
|||
|
|
break;
|
|||
|
|
case 4:
|
|||
|
|
SG4Light.State = Sunny.UI.UILightState.Off;
|
|||
|
|
break;
|
|||
|
|
case 5:
|
|||
|
|
SG5Light.State = Sunny.UI.UILightState.Off;
|
|||
|
|
break;
|
|||
|
|
case 6:
|
|||
|
|
SG6Light.State = Sunny.UI.UILightState.Off;
|
|||
|
|
break;
|
|||
|
|
case 7:
|
|||
|
|
SG7Light.State = Sunny.UI.UILightState.Off;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void bSaveWinName_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
ConfigFileReader.SetValue("/configuration/appSettings/add[@key='DeskName']", TextWinName.Text);
|
|||
|
|
AlertForm.ShowAlert("保存成功", AlertType.Success, 3);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|