コード例 #1
0
        /// <summary>
        /// 数据接收
        /// </summary>
        /// <param name="data"></param>
        public override void DataReceive(string data)
        {
            try
            {
                if (string.IsNullOrEmpty(data))
                {
                    return;
                }
                HJ212Model  model = Deserialize.DeserializeBase(data);
                CommandType type  = Util.GetCommandType((MiddleCode)model.CN);
                switch (type)
                {
                case CommandType.Notice:
                    NoticeResponse(model);
                    break;

                case CommandType.Request:
                    CommandResult res = RequestResponse(model);
                    if (res != CommandResult.Ready)
                    {
                        return;
                    }
                    break;

                case CommandType.Upload:
                    RequestResponse(model, CommandResult.Forbidden);
                    return;

                case CommandType.Other:
                    return;

                case CommandType.None:
                    RequestResponse(model, CommandResult.Forbidden);
                    return;

                default:
                    RequestResponse(model, CommandResult.Forbidden);
                    return;
                }
                switch ((MiddleCode)model.CN)
                {
                case MiddleCode.SetTimeOutReSendTimes:
                    SetTimeOutReSendTimes(model);
                    break;

                case MiddleCode.GetSceneDeviceTime:
                    UploadSceneDeviceTime(model);
                    break;

                case MiddleCode.SetSceneDeviceTime:
                    SetSceneDeviceTime(model);
                    break;

                case MiddleCode.GetRtdDataInterval:
                    UploadRtdDataInterval(model);
                    break;

                case MiddleCode.SetRtdDataInterval:
                    SetRtdDataInterval(model);
                    break;

                case MiddleCode.GetMinuteDataInterval:
                    UploadMinuteDataInterval(model);
                    break;

                case MiddleCode.SetMinuteDataInterval:
                    SetMinuteDataInterval(model);
                    break;

                case MiddleCode.SetSceneDevicePassword:
                    SetSceneDevicePassword(model);
                    break;

                case MiddleCode.GetRtdData:
                    GetRtdData(model);
                    break;

                case MiddleCode.StopRtdData:
                    StopRtdData(model);
                    break;

                case MiddleCode.GetDeviceRunState:
                    GetDeviceRunState(model);
                    break;

                case MiddleCode.StopDeviceRunState:
                    StopDeviceRunState(model);
                    break;

                case MiddleCode.GetDayData:
                    UploadDayData(model);
                    break;

                case MiddleCode.GetDeviceRunTimeDayData:
                    UploadDeviceRunTimeDayData(model);
                    break;

                case MiddleCode.GetMinuteData:
                    UploadMinuteData(model);
                    break;

                case MiddleCode.GetHourData:
                    UploadHourData(model);
                    break;

                case MiddleCode.RangeCalibration:
                    RangeCalibration(model);
                    break;

                case MiddleCode.GetCycleData:
                    UploadCycleData(model);
                    break;

                case MiddleCode.TakeSampleImmediately:
                    TakeSampleImmediately(model);
                    break;

                case MiddleCode.StartClear:
                    StartClear(model);
                    break;

                case MiddleCode.CompareSample:
                    CompareSample(model);
                    break;

                case MiddleCode.LeaveSuperstandardSample:
                    UploadSuperstandardSample(model);
                    break;

                case MiddleCode.SetSampleTimeInterval:
                    SetSampleTimeInterval(model);
                    break;

                case MiddleCode.GetSampleTimeInterval:
                    UploadSampleTimeInterval(model);
                    break;

                case MiddleCode.GetSampleTime:
                    UploadSampleTime(model);
                    break;

                case MiddleCode.GetSceneDeviceUUID:
                    UploadSceneDeviceUUID(model);
                    break;

                case MiddleCode.GetSceneDeviceInfo:
                    UploadSceneDeviceInfo(model);
                    break;

                case MiddleCode.SetSceneDeviceParam:
                    SetSceneDeviceParam(model);
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }