BoltMapEasyService.cs 5.07 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel;
using System.Data;
using System.Collections.ObjectModel;

using Misc;
using FObjBase;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;

namespace FLY.Thick.Base.Client
{
    public class BoltMapEasyService:FObj, IBoltMapEasy
    {
        IFConn mConn;
        UInt32 mServerID;
        public BoltMapEasyService() 
        {
            mServerID = BOLTMAPEASY_OBJ_INTERFACE.ID;
        }
        #region IBoltMapEasy 属性

        private int boltwidth = 100;
        /// <summary>
        /// 平均分区宽度
        /// </summary>
        public int BoltWidth
        {
            get
            {
                return boltwidth;
            }
            set
            {
                if (boltwidth != value)
                {
                    boltwidth = value;
                    NotifyPropertyChanged("BoltWidth");
                }
            }
        }

        private int boltcnt = 90;
        /// <summary>
        /// 平均分区宽度
        /// </summary>
        public int BoltCnt
        {
            get
            {
                return boltcnt;
            }
            set
            {
                if (boltcnt != value)
                {
                    boltcnt = value;
                    NotifyPropertyChanged("BoltCnt");
                }
            }
        }

        private int smooth = 0;
        public int Smooth
        {
            get { return smooth; }
            set
            {
                if (smooth != value)
                {
                    smooth = value;
                    NotifyPropertyChanged("Smooth");
                }
            }
        }

        private int borderboltno_b = 0;
        /// <summary>
        /// 开始边界分区号 
        /// </summary>
        public int BorderBoltNo_B
        {
            get { return borderboltno_b; }
            set
            {
                if (borderboltno_b != value)
                {
                    borderboltno_b = value;
                    NotifyPropertyChanged("BorderBoltNo_B");
                }
            }
        }

        private BORDER_TYPE bordertype;
        /// <summary>
        /// 找边界,边界类型
        /// </summary>
        public BORDER_TYPE BorderType
        {
            get { return bordertype; }
            set
            {
                if (bordertype != value)
                {
                    bordertype = value;
                    NotifyPropertyChanged("BorderType");
                }
            }
        }
        #endregion
        #region INotifyPropertyChanged 成员
        protected void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        public void Apply() 
        {
            BOLTMAPEASY_OBJ_INTERFACE.Pack_Params p = new BOLTMAPEASY_OBJ_INTERFACE.Pack_Params()
            {
                boltwidth = BoltWidth,
                boltcnt = BoltCnt,
                bordertype = BorderType,
                borderboltno_b = BorderBoltNo_B,
                smooth = Smooth
            };
            CurrObjSys.SetValueEx(
                    mConn, mServerID, ID, 
                    BOLTMAPEASY_OBJ_INTERFACE.SET_PARAMS,
                    p.ToBytes());
        }

        public override void Dispose()
        {
            CurrObjSys.ObjRemove(
                this, mConn);
        }
        public override void ConnectNotify(IFConn from)
        {
            mConn = from;
            if (from.IsConnected)
            {
                //获取所有数据,设置推送
                CurrObjSys.GetValueEx(
                    mConn, mServerID, ID, 
                    BOLTMAPEASY_OBJ_INTERFACE.GET_PARAMS);


                CurrObjSys.SenseConfigEx(
                    mConn, mServerID, ID, 0xffffffff,
                    SENSE_CONFIG.ADD);
            }
        }
        public override void PushGetValue(IFConn from, uint srcid, ushort memid, byte[] infodata)
        {
            switch (memid)
            {
                case BOLTMAPEASY_OBJ_INTERFACE.GET_PARAMS:
                    {
                        BOLTMAPEASY_OBJ_INTERFACE.Pack_Params p = new BOLTMAPEASY_OBJ_INTERFACE.Pack_Params();
                        if (p.TryParse(infodata))
                        {
                            BoltCnt = p.boltcnt;
                            BoltWidth = p.boltwidth;
                            BorderType = p.bordertype;
                            BorderBoltNo_B = p.borderboltno_b;
                            Smooth = p.smooth;
                        }
                    } break;
            }
        }
        public override void PushInfo(IFConn from, uint srcid, ushort infoid, byte[] infodata)
        {
            PushGetValue(from, srcid, infoid, infodata);
        }
    }
}