.net Remisol 2000数据管理器的实验室信息系统接口

.net Remisol 2000数据管理器的实验室信息系统接口,.net,integration,.net,Integration,我需要在.NET中开发的实验室信息系统(LIS)和Remisol 2000 Data Manager之间开发一个接口,Remisol 2000 Data Manager是Beckman Coulter Inc.制造的实验室仪器系统的API。其想法是以编程方式将测试结果获取到LIS中 网络上有什么资源可以给我一个开始吗?我假设我需要打开一个套接字,但文档中只提到了诸如Synchron LX20、Synchron CX7、ASTM、ASTMH2和LIS Gen.S等协议的消息结构 它们都使用串行协议

我需要在.NET中开发的实验室信息系统(LIS)和Remisol 2000 Data Manager之间开发一个接口,Remisol 2000 Data Manager是Beckman Coulter Inc.制造的实验室仪器系统的API。其想法是以编程方式将测试结果获取到LIS中

网络上有什么资源可以给我一个开始吗?我假设我需要打开一个套接字,但文档中只提到了诸如Synchron LX20、Synchron CX7、ASTM、ASTMH2和LIS Gen.S等协议的消息结构

它们都使用串行协议

using System;
using System.IO.Ports;
using System.Threading;

public class ClientToBeckmanDL2000
{
    static bool _continue;
    static SerialPort _serialPort;
    static bool keepRetrying = true;

    public static void Main()
    {

        CreateNewSerialPortAndOpenIt();

        SendAndReceiveMessagesInALoop();

        CloseTheSerialPort();
    }

    private static void CloseTheSerialPort()
    {
        _serialPort.Close();
    }

    private static void SendAndReceiveMessagesInALoop()
    {
        StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;
        string outputMessage, inputMessage;
        _continue = true;
        DateTime startTime, endTime;
        TimeSpan diffInSeconds;
        int retryCounter = 0;


        Console.WriteLine("Type QUIT to exit");

        try
        {
            while (_continue)
            {
                outputMessage = Console.ReadLine();

                _serialPort.WriteLine(
                        String.Format("{0}", outputMessage));

                if (outputMessage.Equals("ENQ") || outputMessage.Equals("<ENQ>") ||
                    outputMessage.Equals("EOT SOH") || outputMessage.Equals("<EOT> <SOH>") ||
                    outputMessage.Equals("<EOT><SOH>"))
                {
                    while (keepRetrying.Equals(true))
                    {
                        startTime = DateTime.Now;
                        inputMessage = string.Empty;

                        inputMessage = GetResponseFromServerInALoop();



                        endTime = DateTime.Now;
                        diffInSeconds = endTime - startTime;

                        // if the time for response crosses 15 seconds keep retrying
                        if (diffInSeconds.Seconds > 15)
                        {
                            retryCounter++;
                            keepRetrying = true;
                            Console.WriteLine("Retrying..." + retryCounter.ToString());
                            Console.WriteLine(" ");
                            if (retryCounter > 7)
                            {
                                keepRetrying = false;
                                Console.WriteLine("Tried more than 7 times . Line down. Please try again later...");
                                break;
                            }


                        }
                        else
                            if (inputMessage.ToString().Length > 0 && (inputMessage.Equals("STX")))
                            {
                                Console.WriteLine("Response is " + inputMessage.ToString() + " The Remisol server is bidding for line. Try to send your message later ... ");
                                keepRetrying = false;
                            }
                            else
                                if (inputMessage.ToString().Length > 0 && (!inputMessage.Equals("ACK") && !inputMessage.Equals("NAK") && !inputMessage.Equals("STX")))
                                {
                                    Console.WriteLine("Response is " + inputMessage.ToString() + " It should be ACK or NAK or STX. Try again ... ");
                                    keepRetrying = false;
                                }
                                else
                                    if (inputMessage.ToString().Length > 0 && (inputMessage.Equals("NAK")))
                                    {
                                        Console.WriteLine("Response is " + inputMessage.ToString() + " It should be ACK. Try again ... ");
                                        keepRetrying = false;
                                    }
                                    else
                                    {
                                        Console.WriteLine("Please key in [00,800,01]97<CR><LF> to check Remisol..");
                                        keepRetrying = false;
                                    }
                        if (keepRetrying.Equals(true))
                        {
                            _serialPort.WriteLine(String.Format("{0}", outputMessage));
                        }
                    }
                }
                else
                    if (outputMessage.Equals("[00,800,01]97<CR><LF>"))
                    {
                        do
                        {
                            inputMessage = _serialPort.ReadLine();
                            System.Threading.Thread.Sleep(1000);
                            keepRetrying = false;
                            Console.WriteLine(inputMessage);

                        } while (inputMessage.Equals(null));

                        Console.WriteLine("Response is " + inputMessage.ToString());
                    }
                if (stringComparer.Equals("quit", outputMessage))
                {
                    _continue = false;
                }

            }
        }
        catch (Exception) { }
    }

    private static string GetResponseFromServerInALoop()
    {
        string inputMessage = string.Empty;


        do {
            inputMessage = _serialPort.ReadLine();

            System.Threading.Thread.Sleep(10);
            keepRetrying = false;
            Console.WriteLine(inputMessage);

        }
        while (inputMessage.Equals(string.Empty));

        return inputMessage;
    }

    private static void CreateNewSerialPortAndOpenIt()
    {
        _serialPort = new SerialPort();

        // Allow the user to set the appropriate properties.
        _serialPort.PortName = SetPortName(_serialPort.PortName);
        _serialPort.BaudRate = SetPortBaudRate(_serialPort.BaudRate);
        _serialPort.Parity = SetPortParity(_serialPort.Parity);
        _serialPort.DataBits = SetPortDataBits(_serialPort.DataBits);
        _serialPort.StopBits = SetPortStopBits(_serialPort.StopBits);
        _serialPort.Handshake = SetPortHandshake(_serialPort.Handshake);

        // Set the read/write timeouts
        //_serialPort.ReadTimeout = 0; -- this is being commented since this testing program needs to run for long time without timeouts. The default is anyway 0 which is infinite timeouts
        //_serialPort.WriteTimeout = 500000; -- this too is being commented out since it needs to run infinitely for test

        _serialPort.Open();
    }


    public static string SetPortName(string defaultPortName)
    {
        string portName;

        Console.WriteLine("Available Ports:");
        foreach (string s in SerialPort.GetPortNames())
        {
            Console.WriteLine("   {0}", s);
        }

        Console.Write("COM port({0}): ", defaultPortName);
        portName = Console.ReadLine();

        if (portName == "")
        {
            portName = defaultPortName;
        }
        return portName;
    }

    public static int SetPortBaudRate(int defaultPortBaudRate)
    {
        string baudRate;

        Console.Write("Baud Rate({0}): ", defaultPortBaudRate);
        baudRate = Console.ReadLine();

        if (baudRate == "")
        {
            baudRate = defaultPortBaudRate.ToString();
        }

        return int.Parse(baudRate);
    }

    public static Parity SetPortParity(Parity defaultPortParity)
    {
        string parity;

        Console.WriteLine("Available Parity options:");
        foreach (string s in Enum.GetNames(typeof(Parity)))
        {
            Console.WriteLine("   {0}", s);
        }

        Console.Write("Parity({0}):", defaultPortParity.ToString());
        parity = Console.ReadLine();

        if (parity == "")
        {
            parity = defaultPortParity.ToString();
        }

        return (Parity)Enum.Parse(typeof(Parity), parity);
    }

    public static int SetPortDataBits(int defaultPortDataBits)
    {
        string dataBits;

        Console.Write("Data Bits({0}): ", defaultPortDataBits);
        dataBits = Console.ReadLine();

        if (dataBits == "")
        {
            dataBits = defaultPortDataBits.ToString();
        }

        return int.Parse(dataBits);
    }

    public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
    {
        string stopBits;

        Console.WriteLine("Available Stop Bits options:");
        foreach (string s in Enum.GetNames(typeof(StopBits)))
        {
            Console.WriteLine("   {0}", s);
        }

        Console.Write("Stop Bits({0}):", defaultPortStopBits.ToString());
        stopBits = Console.ReadLine();

        if (stopBits == "")
        {
            stopBits = defaultPortStopBits.ToString();
        }

        return (StopBits)Enum.Parse(typeof(StopBits), stopBits);
    }

    public static Handshake SetPortHandshake(Handshake defaultPortHandshake)
    {
        string handshake;

        Console.WriteLine("Available Handshake options:");
        foreach (string s in Enum.GetNames(typeof(Handshake)))
        {
            Console.WriteLine("   {0}", s);
        }

        Console.Write("Stop Bits({0}):", defaultPortHandshake.ToString());
        handshake = Console.ReadLine();

        if (handshake == "")
        {
            handshake = defaultPortHandshake.ToString();
        }

        return (Handshake)Enum.Parse(typeof(Handshake), handshake);
    }
}
使用系统;
使用System.IO.Ports;
使用系统线程;
公共类ClientToBeckmand2000
{
静态布尔继续;
静态串行端口_SerialPort;
静态bool keepRetrying=true;
公共静态void Main()
{
创建NewSerialPortandOpenIt();
SendAndReceiveMessagesInALoop();
关闭串行端口();
}
私有静态void closeSerialPort()
{
_serialPort.Close();
}
私有静态void sendReceiveMessagesInaloop()
{
StringComparer StringComparer=StringComparer.OrdinalIgnoreCase;
字符串outputMessage,inputMessage;
_继续=真;
日期时间开始时间,结束时间;
时间跨度差异;
int-retryCounter=0;
Console.WriteLine(“键入QUIT以退出”);
尝试
{
while(_continue)
{
outputMessage=Console.ReadLine();
_serialPort.WriteLine(
格式(“{0}”,outputMessage));
if(outputMessage.Equals(“ENQ”)| | outputMessage.Equals(“”)||
outputMessage.Equals(“EOT SOH”)| | outputMessage.Equals(“”)||
outputMessage.Equals(“”)
{
while(keepRetrying.Equals(true))
{
startTime=DateTime.Now;
inputMessage=string.Empty;
inputMessage=GetResponseFromServerInLoop();
endTime=DateTime.Now;
diffinsionds=结束时间-开始时间;
//如果响应时间超过15秒,请继续重试
如果(不同秒数>15)
{
retryCounter++;
不断尝试=正确;
WriteLine(“重试…”+retryCounter.ToString());
控制台。写线(“”);
如果(retryCounter>7)
{
继续尝试=错误;
Console.WriteLine(“尝试了7次以上。请下线。请稍后再试…”);
打破
}
}
其他的
if(inputMessage.ToString().Length>0&(inputMessage.Equals(“STX”))
{
Console.WriteLine(“响应为“+inputMessage.ToString()+”Remisol服务器正在竞标线路。稍后尝试发送您的消息…”);
继续尝试=错误;
}
其他的
如果(inputMessage.ToString().Length>0&&(!inputMessage.Equals(“ACK”)&&&!inputMessage.Equals(“NAK”)&&&&!inputMessage.Equals(“STX”))
{
WriteLine(“响应为“+inputMessage.ToString()+”应为ACK或NAK或STX。请重试…”);
继续尝试=错误;
}
其他的
if(inputMessage.ToString().Length>0&(inputMessage.Equals(“NAK”))
{
Console.WriteLine(“响应为“+inputMessage.ToString()+”应为ACK。请重试…”);
继续尝试=错误;
}
其他的
{
Console.WriteLine(“请输入[00800,01]97以检查Remisol…”);
继续尝试=错误;
}
if(keeppretrying.Equals(true))
{
_serialPort.WriteLine(String.Format(“{0}”,outputMessage));
}
}
}
其他的
if(outputMessage.Equals(“[00800,01]97”))
{
做
{
inputMessage=_serialPort.ReadLine();
系统线程线程睡眠(1000);
继续尝试=错误;
控制台写入线(输入消息);
}while(inputMessage.Equals(null));
WriteLine(“响应为”+inputMessage.ToString());
}
if(stringComparer.Equals(“退出”,outputMessage))
{
_continue=false;
}
}
}
捕获(异常){}
}
私有静态字符串GetResponseFromServerInAlloop()
{
string inputMessage=string.Empty;
做{
inputMessage=_serialPort.ReadLine();
系统线程线程睡眠(10);
继续尝试=错误;
控制台写入线(输入消息);
}
while(inputMessage.Equals(string.Empty));
返回输入消息;
}
私有的