// 验证 LedProperty 的格式正确性 public static NormalResult VerifyLedProperty(LedProperty property) { if (string.IsNullOrEmpty(property.SerialPort)) { return(new NormalResult { Value = -1, ErrorInfo = "SerialPort 尚未指定端口号" }); } if (property.CellXCount > 0) { } else { return new NormalResult { Value = -1, ErrorInfo = "CellXCount (LED 片横向数量)参数格式不正确。应 >= 1" } }; if (property.CellWidth == 0) { property.CellWidth = 64; // 默认 64 } else if (property.CellWidth > 0) { } else { return new NormalResult { Value = -1, ErrorInfo = "CellWidth (LED 单片宽度)参数格式不正确。应 > 0" } }; if (property.CellHeight == 0) { property.CellHeight = 32; // 默认 32 } else if (property.CellHeight > 0) { } else { return new NormalResult { Value = -1, ErrorInfo = "CellHeight (LED 单片高度)参数格式不正确。应 > 0" } }; return(new NormalResult()); } } }
// 初始化时需要提供端口号、LED 片数量、每片像素宽度高度等参数 // parameters: // style 附加的子参数 public NormalResult InitializeDriver(LedProperty property, string style) { _ledProperty = property; var verify_result = VerifyLedProperty(_ledProperty); if (verify_result.Value == -1) { return(verify_result); } return(new NormalResult()); }
set => SetValue(LedProperty, value);