TDGage.cs 5.18 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;

using FObjBase;
using FLY.Thick.Base.Client;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.Common;
using FLY.Thick.BulkDataModule;
using FLY.Thick.BlowingScan.Client;
using FLY.Thick.Blowing.Client;

namespace FLY.Thick.BlowingScan.UI.Client
{
    public class TDGage : ThickTcpUiInWindow.TDGage
    {
        #region 参数--------------------------------------------------------------------

        #region 本地数据----------------------------------------------------------------
        /// <summary>
        /// 系统参数
        /// </summary>
        //public SysParam mSysParam;
27
        public LCUS1 mLCUS;
潘栩锋's avatar
潘栩锋 committed
28 29 30 31 32 33 34 35 36 37
        #endregion
        #region 服务器数据--------------------------------------------------------------


        /// <summary>
        /// 动态数据
        /// </summary>
        public DynArea mDynArea;


38
        public PasswordServiceClient mPasswordService;
潘栩锋's avatar
潘栩锋 committed
39 40 41

        public BlowingScanServiceClient mRenZiJiaService;
        public BlowingDetectServiceClient mBDetect;
42
        public BlowingProfileServiceClient mProfile;
43 44 45 46 47
        public FLY.OBJComponents.Client.WarningServiceClient mWarningService;

        public FLY.OBJComponents.Client.BufferWindow<OBJComponents.Common.FlyData_WarningHistory> mWarningReasonWindow;

        public InitParamServiceClient mInitParamService;
48 49 50 51

        public FlyADServiceClient mFlyAdServiceClient;

        public GetSampleServiceClient mGetSampleServiceClient;
潘栩锋's avatar
潘栩锋 committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
        #endregion

        #endregion

        public TDGage()
        {
            Init1();
        }

        #region Init登陆服务器初始化----------------------------------------------------
        /// <summary>
        /// 第1步, 加载本地数据
        /// </summary>
         void Init1()
        {

            #region 提取保存的数据
            mSysParam = new SysParam();//系统参数
            #endregion

72 73 74 75
            mLCUS = new LCUS1();
            Misc.BindingOperations.SetBinding(mSysParam, "LCUS1_PortName", mLCUS, "PortName");


潘栩锋's avatar
潘栩锋 committed
76
            #region 与服务器同步的数据
77
            mBulkDataClient = new BulkDataServiceClientAdv(new BulkDataServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.BULK_ID));
潘栩锋's avatar
潘栩锋 committed
78

79
            mDynAreaService = new DynAreaServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.DYNAREA_ID);
潘栩锋's avatar
潘栩锋 committed
80 81
            mDynArea = mDynAreaService.mDynArea;

82 83 84 85
            mWarningService = new OBJComponents.Client.WarningServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.WARNING_OBJ_ID);
            //创建窗口观察 报警原因列表
            mWarningReasonWindow = new OBJComponents.Client.BufferWindow<OBJComponents.Common.FlyData_WarningHistory>(mWarningService.ReasonList, 100);

潘栩锋's avatar
潘栩锋 committed
86

87
            mTDGageService = new TDGageServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.TDGAGE_ID);
潘栩锋's avatar
潘栩锋 committed
88

89
            mInitParamService = new InitParamServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.INITPARAM_ID);
潘栩锋's avatar
潘栩锋 committed
90

91
            mFixService = new FixServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.FIX_ID);
潘栩锋's avatar
潘栩锋 committed
92

93 94
            mProfile = new BlowingProfileServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.PROFILE_ID);

95
            mPasswordService = new PasswordServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.PASSWORD_ID);
潘栩锋's avatar
潘栩锋 committed
96

97 98
            mRenZiJiaService = new BlowingScanServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.RENZIJIA_ID);
            mBDetect = new BlowingDetectServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.BDETECT_ID);
99 100
            mFlyAdServiceClient = new FlyADServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.FLYAD_ID);
            mGetSampleServiceClient = new GetSampleServiceClient(OBJ_INTERFACE.OBJ_INTERFACE_ID.GET_SAMPLE_ID);
潘栩锋's avatar
潘栩锋 committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
            #endregion
        }

         TCPCConn conn = null;
        /// <summary>
        /// 第2步, 连接到服务器,初始化参数 。由界面的 【登陆】 按钮触发
        /// </summary>
        public void Init2(IPEndPoint serveripep)
        {

            if(!mSysParam.ServerIPEP.Equals(serveripep))
            {
                mSysParam.ServerIPEP = serveripep;
                mSysParam.Save();
            }
            #region 网络初始化
117
            List<UInt32> objids = new List<UInt32>(new UInt32[]{
潘栩锋's avatar
潘栩锋 committed
118 119 120 121 122 123
                mDynAreaService.ID,
                ((BulkDataServiceClient)(mBulkDataClient.bulkdata)).ID,
                mTDGageService.ID,
                mFixService.ID,
                mPasswordService.ID,
                mRenZiJiaService.ID,
124
                mInitParamService.ID,
125 126 127 128
                mProfile.ID,
                mBDetect.ID,
                mFlyAdServiceClient.ID,
                mGetSampleServiceClient.ID
129 130
            });
            objids.AddRange(mWarningService.GetIDs());
潘栩锋's avatar
潘栩锋 committed
131 132 133 134 135 136

            if (conn != null)
            {
                if (!conn.RemoteEP.Equals(mSysParam.ServerIPEP))
                {
                    //断开之前的连接
137
                    FObjSys.Current.Disconnect_to_Another_OBJSys(conn.RemoteEP, objids.ToArray());
潘栩锋's avatar
潘栩锋 committed
138 139 140
                }
            }

141
            conn = FObjSys.Current.Connect_to_Another_OBJSys(mSysParam.ServerIPEP, objids.ToArray());
潘栩锋's avatar
潘栩锋 committed
142 143 144 145 146 147 148 149 150 151 152 153 154

            #endregion
        }

        public void Init2() 
        {
            Init2(mSysParam.ServerIPEP);
        }
        
        #endregion

    }
}