Ejemplo n.º 1
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new IoTMBCService()
                };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                int port = 9000;
                port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["WCFServicePort"]);

                RegisterWCFService wcf = new RegisterWCFService("localhost", 9000);
                wcf.RunWCFService();
                DataRecordQueueFactory.getInstance().StartService();
                while (true)
                {
                    System.Console.Read();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 向数据中心  数据队列中添加数据
        /// </summary>
        /// <param name="type"></param>
        /// <param name="e"></param>
        public void InsertDataRecord(DataType type, DataArge e)
        {
            if (e.Data != null)
            {
                try
                {
                    switch (type)
                    {
                    case DataType.ReadData:
                        DataRecordQueueFactory.getInstance().AddWork((ReadDataInfo)e.Data);
                        Log.getInstance().Write(MsgType.Information, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}数据中心接收到{type}类型的数据,表号:{((ReadDataInfo)e.Data)._MeterNo} 数据采集时间:{((ReadDataInfo)e.Data)._ReadDate} ST1:{((ReadDataInfo)e.Data)._ST1} ST2:{((ReadDataInfo)e.Data)._ST2}");
                        break;

                    case DataType.WarningData:
                        DataRecordQueueFactory.getInstance().AddWork((WarningInfo)e.Data);
                        Log.getInstance().Write(MsgType.Information, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}数据中心接收到{type}类型的数据,表号:{((WarningInfo)e.Data).meterNo} 数据采集时间:{((WarningInfo)e.Data).readDate} ST1:{((WarningInfo)e.Data).st1} ST2:{((WarningInfo)e.Data).st2}");

                        break;

                    default:
                        break;
                    }
                }
                catch (Exception er)
                {
                    //异常记录
                    Log.getInstance().Write(er, MsgType.Error);
                }
            }
        }
Ejemplo n.º 3
0
 protected override void OnShutdown()
 {
     if (wcf != null)
     {
         wcf.Close();
     }
     DataRecordQueueFactory.getInstance().StopService();
 }
Ejemplo n.º 4
0
        protected override void OnStart(string[] args)
        {
            int port = 9000;

            port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["WCFServicePort"]);
            wcf  = new RegisterWCFService("localhost", port);
            wcf.RunWCFService();
            DataRecordQueueFactory.getInstance().StartService();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            RegisterWCFService wcf = new RegisterWCFService("localhost", 9000);

            wcf.RunWCFService();
            DataRecordQueueFactory.getInstance().StartService();
            while (true)
            {
                System.Console.Read();
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            //string hexstr = "43 8C E8 F5";
            string hexstr = "01 03 04 42 40 66 66 44 15";

            /*01 03 1E
             * 3 00 02
             * 5 43 8F A8 F5
             * 9 00 00
             * 11 02 9A 45 D0
             *
             * 15 55 48 43 3A
             * 19 80 00 44 D0
             * 23 50 00 41 D9
             *
             * 99 9A 00 03 00 20 71 89
             **/

            byte[] data   = strToToHexByte(hexstr);
            int    iIndex = 0;
            //float WenDu = BitConverter.ToSingle(getIEEE(data, iIndex + 3 + 2 + 4 + 6 + 4 + 4), 0);

            //float v = BitConverter.ToSingle(data, 0);
            //System.Console.WriteLine("{0}", WenDu);

            float ZongYongLiang = BytesTouInt16(data, iIndex + 3) * 10000;

            System.Console.WriteLine("{0}", ZongYongLiang);
            ZongYongLiang = BitConverter.ToSingle(getIEEE(data, iIndex + 3), 0);
            System.Console.WriteLine("{0}", ZongYongLiang);

            //int i = 0;
            //while (true)
            //{
            //    System.Console.WriteLine("{0}", Convert.ToByte(new Random().Next(0, 255)));

            //    System.Threading.Thread.Sleep(1000 * 3);
            //    i++;
            //    if (i > 10)
            //        break;
            //}

            int port = 9000;

            port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["WCFServicePort"]);

            RegisterWCFService wcf = new RegisterWCFService("localhost", port);

            wcf.RunWCFService();

            DataRecordQueueFactory.getInstance().StartService();

            System.Console.WriteLine(DataChannelFactoryService.getInstance().StartChannelService());
            DDService.getInstance();


            //new System.Threading.Thread(p =>
            //{
            //    DataService.Business.OneNetChannelService _oneNetService = new DataService.Business.OneNetChannelService();
            //    System.Console.WriteLine(_oneNetService.PostToOneNet("29720180402002", hexstr));
            //    System.Console.WriteLine($"ApartmentState:{System.Threading.Thread.CurrentThread.ApartmentState} CurrentUICulture:{System.Threading.Thread.CurrentThread.CurrentUICulture.Name} CurrentThread.Priority:{System.Threading.Thread.CurrentThread.Priority.ToString()}");
            //}).Start();

            while (true)
            {
                System.Console.Read();
            }
        }