WinderSystemServiceClient.cs 2.98 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
using FLY.OBJComponents.Client;
using FLY.OBJComponents.IService;
using FLY.Winder.Common;
using FLY.Winder.IService;
using FLY.Winder.OBJ_INTERFACE;
using FObjBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace FLY.Winder.Client
{
潘栩锋's avatar
潘栩锋 committed
16
    public class WinderSystemServiceClient : FObjServiceClient, IWinderSystemService
潘栩锋's avatar
潘栩锋 committed
17
    {
潘栩锋's avatar
潘栩锋 committed
18
        #region IWinderSystemService
潘栩锋's avatar
潘栩锋 committed
19 20 21 22 23 24 25 26 27 28 29 30
        public WinderAccessory Accessory { get; private set; }

        public List<WinderInsideOutside> Items { get; private set; }

        /// <summary>
        /// PLC代理系统
        /// </summary>
        public IPLCProxySystemService PLCos { get; private set; }
        #endregion


        SyncPropServiceClient syncPropServiceClient;
潘栩锋's avatar
潘栩锋 committed
31 32 33 34 35 36 37 38 39 40
        
        /// <summary>
        /// 当前 INotifyPropertyChanged 对象 引发了 PropertyChanged,  是由于 接收到数据导致的
        /// </summary>
        public bool IsInPushValue {
            get
            {
                return syncPropServiceClient.IsInPushValue;
            }
        }
潘栩锋's avatar
潘栩锋 committed
41
        public WinderSystemServiceClient(UInt32 serviceId) : base(serviceId)
潘栩锋's avatar
潘栩锋 committed
42
        {
潘栩锋's avatar
潘栩锋 committed
43 44
            Init();
        }
潘栩锋's avatar
潘栩锋 committed
45

潘栩锋's avatar
潘栩锋 committed
46 47 48 49 50 51 52 53
        public WinderSystemServiceClient(UInt32 serviceId, string connName) : base(serviceId)
        {
            Init();
            ConnName = connName;
            FObjServiceClientManager.Instance.Connect_to_Another_OBJSys(connName, this);
        }
        void Init() 
        { 
潘栩锋's avatar
潘栩锋 committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
            Items = new List<WinderInsideOutside>();
            for (int i = 0; i < 2; i++)
            {
                Items.Add(new WinderInsideOutside());
            }
            Accessory = new WinderAccessory();

            
            syncPropServiceClient = new SyncPropServiceClient(
                mServerID + 1, 
                new Dictionary<string, INotifyPropertyChanged>
                {
                    {"Accessory", Accessory },
                    {"Items[0]", Items[0] },
                    {"Items[1]", Items[1] }
                });
            

            PLCos = new PLCProxySystemServiceClient(
潘栩锋's avatar
潘栩锋 committed
73
                mServerID + 2,
潘栩锋's avatar
潘栩锋 committed
74 75 76 77 78 79 80
                new Dictionary<string, INotifyPropertyChanged> 
                {
                    {"Accessory", Accessory },
                    {"Items[0]", Items[0] },
                    {"Items[1]", Items[1] }
                });
        }
潘栩锋's avatar
潘栩锋 committed
81 82
        
        public override UInt32[] GetIDs()
潘栩锋's avatar
潘栩锋 committed
83 84 85 86 87 88 89 90 91 92 93
        {
            List<UInt32> IDs = new List<uint>();
            IDs.Add(ID);
            IDs.Add(syncPropServiceClient.ID);
            IDs.AddRange(((PLCProxySystemServiceClient)PLCos).GetIDs());

            return IDs.ToArray();
        }

        public override void ConnectNotify(IFConn from)
        {
潘栩锋's avatar
潘栩锋 committed
94
            base.ConnectNotify(from);
潘栩锋's avatar
潘栩锋 committed
95 96 97 98 99 100 101 102
            if (from.IsConnected)
            {
                CurrObjSys.SenseConfigEx(mConn, mServerID, ID,
                    0xffffffff, SENSE_CONFIG.ADD);
            }
        }
    }
}