TDGage.cs 4.16 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;

using FObjBase;
using Misc;
10
using FLY.FeedbackRenZiJia.Server.Model;
潘栩锋's avatar
潘栩锋 committed
11 12 13

namespace FLY.FeedbackRenZiJia.Server
{
14
    public class TDGage
潘栩锋's avatar
潘栩锋 committed
15 16 17 18 19 20 21
    {
        #region 参数--------------------------------------------------------------------
        #region 初始化------------------------------------------------------------------
        public string mParamDirectory;//参数目录 m_path;//数据文件的 根目录默认是 Gage1
        public string mName;//名字 如:gage0
        #endregion
        #region 本地数据----------------------------------------------------------------
22
        public SysParam mSysParam;
潘栩锋's avatar
潘栩锋 committed
23 24 25
        public FeedbackHeat mfeedback;
        #endregion
        #region 服务器数据--------------------------------------------------------------
26 27 28 29 30

       
        public FLY.Thick.Blowing.Client.BlowingServiceClient mRenZiJia;

        public FLY.Thick.Blowing.Client.BlowingDetectServiceClient mBDetect;
潘栩锋's avatar
潘栩锋 committed
31 32

        /// <summary>
33
        /// 报警系统
潘栩锋's avatar
潘栩锋 committed
34
        /// </summary>
35
        public FLY.OBJComponents.Server.WarningSystem mWarning;
潘栩锋's avatar
潘栩锋 committed
36

37
        public HistoryDb mHistoryDb;
潘栩锋's avatar
潘栩锋 committed
38

潘栩锋's avatar
潘栩锋 committed
39
        DbModel mDbModel;
40
        
潘栩锋's avatar
潘栩锋 committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        #endregion
        #endregion


        public TDGage(string nam)
        {
            mName = nam;
            mParamDirectory = mName;// @"D:\" + m_name;

            if (!System.IO.Directory.Exists(mParamDirectory))
            {
                System.IO.Directory.CreateDirectory(mParamDirectory);
            }
            System.Environment.CurrentDirectory = mParamDirectory;

56

潘栩锋's avatar
潘栩锋 committed
57 58 59 60 61 62 63 64 65 66 67
            Init1();

        }


        #region Init登陆服务器初始化----------------------------------------------------
        /// <summary>
        /// 第1步, 加载本地数据
        /// </summary>
        public void Init1()
        {
68
            mSysParam = new SysParam();
潘栩锋's avatar
潘栩锋 committed
69 70

            #region 与服务器同步的数据
潘栩锋's avatar
潘栩锋 committed
71
            
潘栩锋's avatar
潘栩锋 committed
72

73
            mRenZiJia = new FLY.Thick.Blowing.Client.BlowingServiceClient(FLY.Thick.Blowing.OBJ_INTERFACE.OBJ_INTERFACE_ID.RENZIJIA_ID);
潘栩锋's avatar
潘栩锋 committed
74

75
            mBDetect = new Thick.Blowing.Client.BlowingDetectServiceClient(FLY.Thick.Blowing.OBJ_INTERFACE.OBJ_INTERFACE_ID.BDETECT_ID);
潘栩锋's avatar
潘栩锋 committed
76 77 78 79
            #endregion

            #region 提取保存的数据

80 81 82 83 84 85 86 87
            //---------------------------------------------------------------------------------------------------------------
            //数据库
            mDbModel = new DbModel();
            mDbModel.Init();

            mHistoryDb = new HistoryDb();
            mHistoryDb.Init(mDbModel);
            mHistoryDb.KeepDBSize(mSysParam.DBKeepMonth);
潘栩锋's avatar
潘栩锋 committed
88 89 90 91 92
            //PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, () =>
            //{
            //    //避免1个月都不关程序,每天检查一次
            //    mHistoryDb.KeepDBSize(mSysParam.DBKeepMonth);
            //}, TimeSpan.FromDays(1));
93 94 95

            //---------------------------------------------------------------------------------------------------------------
            //Warning_Create
96 97
            mWarning = new FLY.OBJComponents.Server.WarningSystem();
            mWarning.Init(mHistoryDb.ErrorBuffer);
98 99 100 101 102 103 104 105 106 107 108 109 110
            Misc.BindingOperations.SetBinding(mWarning, "IsRinging", () =>
            {
                //报警不动作
                if (mWarning.IsRinging)
                {

                }
                else
                {

                }
            });

潘栩锋's avatar
潘栩锋 committed
111

潘栩锋's avatar
潘栩锋 committed
112
            mfeedback = new FeedbackHeat();
潘栩锋's avatar
潘栩锋 committed
113 114 115


            mfeedback.Init(
潘栩锋's avatar
潘栩锋 committed
116
                mRenZiJia,
117 118 119
                mBDetect,
                mWarning,
                mHistoryDb
潘栩锋's avatar
潘栩锋 committed
120 121
                );
            
潘栩锋's avatar
潘栩锋 committed
122

潘栩锋's avatar
潘栩锋 committed
123 124 125 126 127 128 129 130 131 132 133 134
            #endregion

            Init2();
        }

        /// <summary>
        /// 第2步, 连接到服务器,初始化参数 。由界面的 【登陆】 按钮触发
        /// </summary>
        private void Init2()
        {
            #region 网络初始化
            FObjSys.Current.Connect_to_Another_OBJSys( 
135
                mSysParam.ServerIPEP, 
潘栩锋's avatar
潘栩锋 committed
136 137 138 139 140 141 142 143 144 145 146
                mRenZiJia.ID,
                mBDetect.ID
                );

            #endregion
        }

        #endregion

    }
}