private DirectiveResult ParsePausingResultData(byte[] bytes) { var ret = new DirectiveResult(); if (!DirectiveHelper.IsValidationResult(bytes, ((DirectiveTypeEnum)bytes[1]).GetFeedbackLength())) { ret.Status = false; return(ret); } ret.Status = true; var data = new RockerDirectiveData(); data.DeviceId = bytes[0]; data.DirectiveType = (DirectiveTypeEnum)bytes[1]; data.TimeInterval = (int)DirectiveHelper.Parse2BytesToNumber(bytes.Skip(2).Take(2).ToArray()); data.Speed = DirectiveHelper.Parse2BytesToNumber(bytes.Skip(4).Take(2).ToArray()); data.DeviceStatus = bytes.Skip(6).Take(1).FirstOrDefault(); data.DirectiveId = (int)DirectiveHelper.Parse2BytesToNumber(bytes.Skip(7).Take(2).ToArray()); data.DeviceType = TargetDeviceTypeEnum.Rocker; ret.SourceDirectiveType = DirectiveTypeEnum.Pausing; ret.Data = data; return(ret); }
private DirectiveResult ParseNormalRunningResultData(byte[] bytes) { var ret = new DirectiveResult(); ret.Status = true; var data = new RockerDirectiveData(); data.DeviceId = bytes[0]; data.DirectiveType = (DirectiveTypeEnum)bytes[1]; data.Angle = (double)DirectiveHelper.Parse2BytesToNumber(bytes.Skip(2).Take(2).ToArray()) / 10; data.Speed = DirectiveHelper.Parse2BytesToNumber(bytes.Skip(4).Take(2).ToArray()); data.DeviceStatus = bytes.Skip(6).Take(1).FirstOrDefault(); data.RockMode = (RockEnum)bytes.Skip(7).Take(1).FirstOrDefault(); data.DirectiveId = (int)DirectiveHelper.Parse2BytesToNumber(bytes.Skip(8).Take(2).ToArray()); data.DeviceType = TargetDeviceTypeEnum.Rocker; ret.SourceDirectiveType = DirectiveTypeEnum.Running; ret.Data = data; return(ret); }
private DirectiveResult ParseLongRunningResultData(byte[] bytes) { var ret = new DirectiveResult(); ret.Status = true; var data = new RockerDirectiveData(); data.DeviceId = bytes[0]; data.DirectiveType = (DirectiveTypeEnum)bytes[1]; data.CenterTemperature = DirectiveHelper.Parse2BytesToNumber(bytes.Skip(2).Take(2).ToArray()) / 10; data.Speed = DirectiveHelper.Parse2BytesToNumber(bytes.Skip(4).Take(2).ToArray()); data.HeaterTemperature = DirectiveHelper.Parse2BytesToNumber(bytes.Skip(6).Take(2).ToArray()) / 10; data.EnvTemperature = DirectiveHelper.Parse2BytesToNumber(bytes.Skip(8).Take(2).ToArray()) / 10; data.DirectiveId = (int)DirectiveHelper.Parse2BytesToNumber(bytes.Skip(10).Take(2).ToArray()); data.DeviceType = TargetDeviceTypeEnum.Rocker; ret.SourceDirectiveType = DirectiveTypeEnum.Running; ret.Data = data; return(ret); }
private DirectiveResult ParseTryStartResultData(byte[] bytes) { var ret = new DirectiveResult(); if (!DirectiveHelper.IsValidationResult(bytes, ((DirectiveTypeEnum)bytes[1]).GetFeedbackLength())) { ret.Status = false; return(ret); } ret.Status = true; var data = new RockerDirectiveData(); data.DeviceId = bytes[0]; data.DirectiveType = (DirectiveTypeEnum)bytes[1]; data.DirectiveId = (int)DirectiveHelper.Parse2BytesToNumber(bytes.Skip(2).Take(2).ToArray()); data.DeviceType = TargetDeviceTypeEnum.Rocker; ret.SourceDirectiveType = DirectiveTypeEnum.TryStart; ret.Data = data; return(ret); }