using System;
using System.IO;
using System.IO.Pipes;
using System.Threading;
namespace TempFlansh
{
internal static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
private static void Main()
{
Console.WriteLine("Comport");
short cport = short.Parse(Console.ReadLine());
var ap = TempHelper.UniversalOpenCom(cport, 4800, 8, 0, 0);
var helper = new TempHelper();
//var filename = $"{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}_temp.log";
////while (true)
////{
//// var outT = $"{DateTime.Now} {helper.ReadCurrentDisplayValue().ToString()}";
//// File.AppendAllLines(filename, new List() { outT });
//// Console.WriteLine(outT);
//// Thread.Sleep(1000);
////}
while (true)
{
using (NamedPipeServerStream pipeServer = new NamedPipeServerStream("TempPipe", PipeDirection.Out))
{
Console.WriteLine("NamedPipeServerStream object created.");
// Wait for a client to connect
Console.Write("Waiting for client connection...");
pipeServer.WaitForConnection();
Console.Write("Open Comport");
Console.WriteLine("Client connected.");
try
{
// Read user input and send that to the client process.
using (StreamWriter sw = new StreamWriter(pipeServer))
{
sw.AutoFlush = true;
while (pipeServer.IsConnected)
{
//sw.WriteLine("19.0");
sw.WriteLine(helper.ReadCurrentDisplayValue().ToString());
Console.WriteLine(helper.ReadCurrentDisplayValue().ToString());
Thread.Sleep(500);
}
}
}
// Catch the IOException that is raised if the pipe is broken
// or disconnected.
catch (IOException e)
{
Console.WriteLine("ERROR: {0}", e.Message);
}
}
}
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
}
}
}