Exemple #1
0
        public static void Main()
        {
            //Logger2.Write("hello");
            //try
            //{
            //    string a = "ff";
            //    int b = Convert.ToInt32(a);


            //}
            //catch (Exception ex)
            //{

            //    Logger2.Write(ex.Message);

            //}
            Stopwatch st = new Stopwatch();

            st.Start();
            string mg = "handshake error, plc init failed 在 System.Net.Sockets.Socket.Connect(IPAddress[] addresses, Int32 port)在 System.Net.Sockets.Socket.Connect(String host, Int32 port)在 PLCCommunicationKit.SocketBaseKit.SocketBase.initSocketBase(String ip, Int32 ";

            System.Threading.Tasks.Parallel.For(0, 1000, x =>
            {
                Logger2.Infor("test" + x.ToString());
                Logger2.Error(mg + x.ToString());
                //Console.WriteLine(x);
            });
            st.Stop();
            Console.WriteLine(st.ElapsedMilliseconds);
            Console.ReadKey();
        }
Exemple #2
0
        public void InitPipe()
        {
            try
            {
                ChildPipeClient_1 = new NamedPipeClientStream(".", "np1", PipeDirection.In);  //所有管道都在使用中,父子说明重复了
                ChildPipeServer_2 = new NamedPipeServerStream("np2", PipeDirection.Out);
                sr_1 = new StreamReader(ChildPipeClient_1);
                sw_2 = new StreamWriter(ChildPipeServer_2);

                ChildPipeClient_1.Connect(); //此处的顺序很重要,必须与服务器向匹配,否则会一直阻塞
                ChildPipeServer_2.WaitForConnection();
                sw_2.AutoFlush = true;
                //reconnecting  只有客户端
                //ReConnect();
                Logger2.Infor("pipe connected 02");
                StartPipeThread();
            }
            catch (Exception ex)
            {
                Logger2.Error(ex.Message);
                ChildPipeClient_1.Close();
                ChildPipeServer_2.Close();
                sr_1.Close();
                sw_2.Close();
                MessageBox.Show(ex.Message, "子进程");
                // throw;
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            try
            {
                Logger2.Infor("inside sub process 01");
                if (args.Length > 0)
                {
                    CpuType             cpu = (CpuType)Convert.ToInt32(args[0]);
                    string              ip  = args[1];
                    CreateSocketProcess cs  = new CreateSocketProcess(cpu, ip);
                    MyProxy = cs.MyPlcInstance;
                    MyProxy.Open();

                    //cs.DB = Convert.ToInt32(args[2]);
                    //cs.StartAddr = Convert.ToInt32(args[3]);
                    //cs.ReadCount = Convert.ToInt32(args[4]);

                    #region MyRegion
                    //pip communicate
                    //foreach (string s in args)
                    //{
                    //    Logger2.Infor("args is :" + s);
                    //}
                    // Console.WriteLine(args[0]);
                    //sw.WriteLine("client recieved :"+temp);
                    #endregion
                    PipeHelper ph = new PipeHelper();
                    ph.InitPipe();
                    //ReadPlcAndWritePipe(cs, MyProxy);
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("wrong input para number,please check");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                Logger2.Error(ex.Message);
                MessageBox.Show(ex.Message, "子进程提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #4
0
 public static void Error(Guid correlationId, string content, string action = "", string tag = "", string component = "", string hostName = "", string envInfo = "")
 {
     Logger2.Error(correlationId, content, action, tag, component, hostName, envInfo);
 }