예제 #1
0
        private static void ReadPlcAndWritePipe(CreateSocketProcess cs, Plc MyProxy)
        {
            while (true)
            {
                Thread.Sleep(1000);
                //byte[] res = MyProxy.ReadBytes(DataType.DataBlock, cs.DB, cs.StartAddr, cs.ReadCount);
                //object res1 = MyProxy.Read(DataType.DataBlock, cs.DB, cs.StartAddr, VarType.Int, cs.ReadCount);
                //List<Int16> res1 = (List<Int16>)MyProxy.Read(DataType.DataBlock, cs.DB, cs.StartAddr, VarType.Int, cs.ReadCount);
                //Int16 res1 = (Int16)MyProxy.Read(DataType.DataBlock, cs.DB, cs.StartAddr, VarType.Int, cs.ReadCount);

                Int32 res3 = (Int32)MyProxy.Read(DataType.DataBlock, cs.DB, cs.StartAddr, VarType.DInt, cs.ReadCount);

                PipeHelper.sw_2.WriteLine(res3);
            }
        }
예제 #2
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);
            }
        }