예제 #1
0
        /// <summary>
        /// 获取监视情况
        /// </summary>
        /// <returns></returns>
        public DataArge GetMonitorInfo()
        {
            //表连接个数
            int linkCount = 0;

            ICreateDataChannel[] dataChannel = DataChannelFactoryService.getInstance().DataChannelFactory;
            for (int i = 0; i < dataChannel.Length; i++)
            {
                linkCount += dataChannel[i].GetConectionCount();
            }
            const int   GB_DIV      = 1024 * 1024 * 1024;
            float       _tmp        = 0;//内存G
            MonitorInfo monitorinfo = new MonitorInfo();

            if (systeminfo != null)
            {
                //使用物理内存
                _tmp = (systeminfo.PhysicalMemory - systeminfo.MemoryAvailable) / (float)GB_DIV;
                monitorinfo.LinkCount = linkCount;
                monitorinfo.Cpu       = float.Parse(systeminfo.CpuLoad.ToString("#0.00"));
                monitorinfo.Memory    = float.Parse(_tmp.ToString("#0.00"));
            }
            else
            {
                monitorinfo.LinkCount = 0;
                monitorinfo.Cpu       = 0;
                monitorinfo.Memory    = 0;
            }
            return(new DataArge(DataType.MonitorData, monitorinfo));
        }
예제 #2
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new IotMService()
                };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                System.Console.WriteLine(DataChannelFactoryService.getInstance().StartChannelService());
                DDService.getInstance();

                while (true)
                {
                    System.Console.Read();
                }
            }
        }
예제 #3
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();
            }
        }
예제 #4
0
 protected override void OnShutdown()
 {
     DataChannelFactoryService.getInstance().StopChannelService();
     DDService.getInstance().UnRegister();
 }
예제 #5
0
 protected override void OnStart(string[] args)
 {
     DataChannelFactoryService.getInstance().StartChannelService();
     DDService.getInstance();
 }