using ECG_System.Mode;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Script.Serialization;
public static string pid { get; set; }
public static bool isrun { get; set; }
public static bool isruning { get; set; }
public static void run()
{
List<IpAddr> list = new List<IpAddr>(); //list 存IP
var BloodOip = new IpAddr(BloodO_ip, BloodO_port);
var Ecgip = new IpAddr(Ecg_ip, Ecg_port);
var bloodPip = new IpAddr(bloodP_ip, bloodP_port);
list.Add(BloodOip);
list.Add(Ecgip);
list.Add(bloodPip);
if (isruning == false)
{
td = new Thread[3];
td[0] = new Thread(StartListen);
td[1] = new Thread(StartListen);
td[2] = new Thread(StartListen);
for (int i = 0; i < td.Length; i++)
{
td[i].Start(list[i]);
}
}
}
public static void stop()
{
if (td.Length > 0)
{
for (int i = 0; i < td.Length; i++)
{
td[i].Abort();
}
}
if (client.Connected)
{
client.Close();
isruning = false;
}
}
private static string GetCard(string pid)
{
string result = "";
var arr = pid.Split(‘,‘); //把带逗号的字符串转换成字符串数组
if (arr.Length >= 6)
{
for (int i = 0; i < 6; i++)
{
result += arr[i] + ",";
}
}
return result.TrimEnd(‘,‘);//删除最后一个逗号
}
}
public class IpAddr
{
public IpAddr(string ip, string port)
{
this.ip = ip;
this.port = int.Parse(port);
}
public string ip { get; set; }
public int port { get; set; }