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

潘栩锋's avatar
1  
潘栩锋 committed
13 14
namespace FLY.Thick.Base.Client
{
15 16 17 18
    /// <summary>
    /// 系统参数服务 客户端代理
    /// </summary>
    public class InitParamServiceClient : FObjServiceClient, IInitParamService
潘栩锋's avatar
1  
潘栩锋 committed
19
    {
20 21 22 23 24 25 26 27 28 29 30 31 32

        /// <summary>
        /// 系统参数服务 客户端代理 构造
        /// </summary>
        /// <param name="id">服务Id</param>
        public InitParamServiceClient(UInt32 id) : base(id) { }

        /// <summary>
        /// 系统参数服务 客户端代理 构造
        /// </summary>
        /// <param name="serviceId">服务Id</param>
        /// <param name="connName">连接器</param>
        public InitParamServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }
潘栩锋's avatar
1  
潘栩锋 committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53



        #region 属性,成员变量的代理

        /// <summary>
        /// 扫描架长
        /// </summary>
        public int PosLength { get; set; } = 8900;
        
        /// <summary>
        /// 自动归原点间距
        /// </summary>
        public int AutoOrgInterval { get; set; } = 30;


        /// <summary>
        /// 从 flyad7 获取的
        /// </summary>
        public int PosOfGrid { get; set; } = 10;

潘栩锋's avatar
潘栩锋 committed
54 55 56 57
        /// <summary>
        /// timeGridAdv 使能
        /// </summary>
        public bool IsTimeGridAdvEnabled { get; set; }
潘栩锋's avatar
1  
潘栩锋 committed
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
        /// <summary>
        /// ad 滞后量  ms
        /// </summary>
        public int ADLag { get; set; } = 0;


        /// <summary>
        /// 编码器1 mm/pulse
        /// </summary>
        public double Encoder1_mmpp { get; set; } = 0.1;


        /// <summary>
        /// 设置的速度,与 实际速度比例
        /// </summary>
        public double Speed1Scale { get; set; } =1;

        /// <summary>
        /// 线速度来源
        /// </summary>
        public FilmVSRC FilmVSrc { get; set; } = FilmVSRC.ROUND;

        /// <summary>
        /// 最小线速度 m/min
        /// </summary>
        public int FilmVThreshold { get; set; } = 5;



        /// <summary>
        /// 编码器2 mm/pulse
        /// </summary>
        public double Encoder2_mmpp { get; set; } = 0.1;



        /// <summary>
        /// 编码器2 放大
        /// </summary>
        public float Encoder2_comp { get; set; } = 1;


        /// <summary>
        /// //1圈多少mm
        /// </summary>
        public double MmOfR { get; set; } = 314;


    
        /// <summary>
        /// 数据有效源
        /// </summary>
        public DATAVALIDSRC DataValidSrc { get; set; } = DATAVALIDSRC.VALID;


        /// <summary>
        /// 当数据有效状态改变,自动按F1,F3
        /// </summary>
        public bool AutoF1F3 { get; set; }


        /// <summary>
        /// 当数据有效状态  无效->有效 ,等待多久重新扫描 ,单位s
        /// </summary>
        public int ReStartDelay { get; set; } = 5;


        #region 速度

        /// <summary>
        /// 扫描时速度
        /// </summary>
        public UInt32 VScan { get; set; } = 8000;


        /// <summary>
        /// 调试时速度,向前走,向后走
        /// </summary>
        public UInt32 VJOG { get; set; } = 5000;


        /// <summary>
        /// 精确速度 Velocity Of Accuracy  如: 机架修正, 样品取样, 机架信息获取
        /// </summary>
        public UInt32 VAccuracy { get; set; } = 3000;

        /// <summary>
        /// 开始速度 Start Velocity
        /// </summary>
        public UInt32 SVelocity { get; set; } = 500;


        /// <summary>
        /// 加速时间
        /// </summary>
        public UInt32 ATime { get; set; } = 200;

        /// <summary>
        /// 减速时间
        /// </summary>
        public UInt32 DTime { get; set; } = 200;
        
        /// <summary>
        /// 归0速度1
        /// </summary>
        public UInt32 HVelocity1 { get; set; } = 5000;


        /// <summary>
        /// 归0速度2
        /// </summary>
        public UInt32 HVelocity2 { get; set; } = 1000;

        #endregion



        /// <summary>
        /// 有按样标定硬件
        /// </summary>
        public bool HasProfileSample { get; set; }

        /// <summary>
        /// 有小托辊
        /// </summary>
        public bool HasHold { get; set; }

185 186 187 188
        /// <summary>
        /// 数据库保存的月数
        /// </summary>
        public int DBKeepMonth { get; set; }
潘栩锋's avatar
潘栩锋 committed
189 190 191 192
        /// <summary>
        /// 数据库路径
        /// </summary>
        public string DbPath { get; set; }
潘栩锋's avatar
1  
潘栩锋 committed
193 194 195 196 197 198 199 200
        #endregion

        public void Apply() 
        {
            INITPARAM_OBJ_INTERFACE.Pack_Params p = new INITPARAM_OBJ_INTERFACE.Pack_Params()
            {
                poslength = PosLength,
                auto_org_interval = AutoOrgInterval,
潘栩锋's avatar
潘栩锋 committed
201
                isTimeGridAdvEnabled = IsTimeGridAdvEnabled,
潘栩锋's avatar
1  
潘栩锋 committed
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
                adlag = ADLag,

                encoder1_mmpp = Encoder1_mmpp,
                speed1scale = Speed1Scale,

                filmVSrc= FilmVSrc, 
                filmVThreshold = FilmVThreshold,
                encoder2_mmpp = Encoder2_mmpp,
                mmOfR = MmOfR,
                encoder2_comp = Encoder2_comp,
                data_valid_src = DataValidSrc,
                autof1f3 = AutoF1F3,
                restartDelay = ReStartDelay,

                vscan = VScan,
                vjog = VJOG,
                vaccuracy = VAccuracy,
                svelocity = SVelocity,
                atime = ATime,
                dtime = DTime,
                hvelocity1 = HVelocity1,
                hvelocity2 = HVelocity2,

                hasProfileSample = HasProfileSample,
226
                hasHold = HasHold,
潘栩锋's avatar
潘栩锋 committed
227 228 229
                dBKeepMonth = DBKeepMonth,
                dbPath = DbPath
                
潘栩锋's avatar
1  
潘栩锋 committed
230
            };
231
            string json = JsonConvert.SerializeObject(p);
潘栩锋's avatar
1  
潘栩锋 committed
232 233 234 235 236

            //获取所有数据,设置推送
            CurrObjSys.SetValueEx(
                mConn, mServerID, ID, 
                INITPARAM_OBJ_INTERFACE.SET_PARAMS,
237
                Misc.Converter.StringToBytes(json));
潘栩锋's avatar
1  
潘栩锋 committed
238
        }
239

潘栩锋's avatar
1  
潘栩锋 committed
240 241
        public override void ConnectNotify(IFConn from)
        {
242
            base.ConnectNotify(from);
潘栩锋's avatar
1  
潘栩锋 committed
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
            if (from.IsConnected)
            {
                //获取所有数据,设置推送
                CurrObjSys.GetValueEx(
                    mConn, mServerID, ID, 
                    BORDERSEARCH_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 INITPARAM_OBJ_INTERFACE.GET_PARAMS:
                    {
259
                        string json = Misc.Converter.BytesToString(infodata);
潘栩锋's avatar
1  
潘栩锋 committed
260

261 262
                        var p = JsonConvert.DeserializeObject<INITPARAM_OBJ_INTERFACE.Pack_Params>(json);
                        
潘栩锋's avatar
1  
潘栩锋 committed
263 264 265
                        PosLength = p.poslength;
                        AutoOrgInterval = p.auto_org_interval;
                        PosOfGrid = p.posOfGrid;
潘栩锋's avatar
潘栩锋 committed
266
                        IsTimeGridAdvEnabled = p.isTimeGridAdvEnabled;
潘栩锋's avatar
1  
潘栩锋 committed
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
                        ADLag = p.adlag;

                        Encoder1_mmpp = p.encoder1_mmpp;
                        Speed1Scale = p.speed1scale;

                        FilmVSrc = p.filmVSrc;
                        FilmVThreshold = p.filmVThreshold;
                        Encoder2_mmpp = p.encoder2_mmpp;
                        Encoder2_comp = p.encoder2_comp;
                        MmOfR = p.mmOfR;
                        DataValidSrc = p.data_valid_src;

                        AutoF1F3 = p.autof1f3;
                        ReStartDelay = p.restartDelay;


                        VScan = p.vscan;
                        VJOG = p.vjog;
                        VAccuracy = p.vaccuracy;
                        SVelocity = p.svelocity;
                        ATime = p.atime;
                        DTime = p.dtime;
                        HVelocity1 = p.hvelocity1;
                        HVelocity2 = p.hvelocity2;

                        HasProfileSample = p.hasProfileSample;
                        HasHold = p.hasHold;
294
                        DBKeepMonth = p.dBKeepMonth;
潘栩锋's avatar
潘栩锋 committed
295
                        DbPath = p.dbPath;
潘栩锋's avatar
1  
潘栩锋 committed
296 297 298 299 300 301 302 303 304 305
                    } break;

            }
        }
        public override void PushInfo(IFConn from, uint srcid, ushort infoid, byte[] infodata)
        {
            PushGetValue(from, srcid, infoid, infodata);
        }
    }
}