示例#1
0
        /// <summary>
        /// 设置采样时间周期
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static SetSampleTimeIntervalModel SetSampleTimeInterval(string context)
        {
            SetSampleTimeIntervalModel setSampleTimeIntervalModel = new SetSampleTimeIntervalModel();

            string[] dataArray = context.Split(';');
            foreach (string data in dataArray)
            {
                string[] cmdArray = data.Split('=');
                if (cmdArray[0] == "PolId")
                {
                    setSampleTimeIntervalModel.PolId = cmdArray[1];
                }
                if (cmdArray[0] == "CstartTime")
                {
                    setSampleTimeIntervalModel.CstartTime = cmdArray[1];
                }
                if (cmdArray[0] == "CTime")
                {
                    setSampleTimeIntervalModel.CTime = Convert.ToInt16(cmdArray[1]);
                }
            }
            return(setSampleTimeIntervalModel);
        }
        /// <summary>
        /// 设置采样时间周期
        /// </summary>
        private void SetSampleTimeInterval(HJ212Model model)
        {
            string content = string.Empty;
            SetSampleTimeIntervalModel setSampleTimeIntervalModel = Deserialize.SetSampleTimeInterval(model.CP);

            if (string.IsNullOrEmpty(setSampleTimeIntervalModel.PolId) ||
                string.IsNullOrEmpty(setSampleTimeIntervalModel.CstartTime) ||
                setSampleTimeIntervalModel.CTime == null)
            {
                content = Serialize.ExecuteResponse(config, model.QN, ExecuteResult.CommandError);
            }
            else
            {
                ParamCodeConfig param = config.ParamCodes.FirstOrDefault(x => x.ParamCode == setSampleTimeIntervalModel.PolId);
                if (null != param)
                {
                    param.CstartTime = setSampleTimeIntervalModel.CstartTime;
                    param.CTime      = (int)setSampleTimeIntervalModel.CTime;
                    ReWriteConfig();
                }
                content = Serialize.ExecuteResponse(config, model.QN, ExecuteResult.Success);
            }
            SendData(content);
        }