Skip to content

Commit

Permalink
improve name of access rule properties
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed Apr 1, 2024
1 parent f319c4d commit e0bbb71
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@ IReadOnlyList<EchonetPropertySpecification> properties
/// </summary>
public IEnumerable<EchonetPropertySpecification> GetProperties
{
get { return Properties.Where(static p => p.Get); }
get { return Properties.Where(static p => p.CanGet); }
}
/// <summary>
/// 仕様上定義済みのSETプロパティの一覧
/// </summary>
public IEnumerable<EchonetPropertySpecification> SetProperties
{
get { return Properties.Where(static p => p.Set); }
get { return Properties.Where(static p => p.CanSet); }
}
/// <summary>
/// 仕様上定義済みのANNOプロパティの一覧
/// </summary>
public IEnumerable<EchonetPropertySpecification> AnnoProperties
{
get { return Properties.Where(static p => p.Anno); }
get { return Properties.Where(static p => p.CanAnnounceStatusChange); }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ internal static EchonetPropertySpecification CreateUnknown(byte code)
logicalDataType: "Unknown",
minSize: null,
maxSize: null,
get: false,
getRequired: false,
set: false,
setRequired: false,
anno: false,
annoRequired: false,
canGet: false,
isGetMandatory: false,
canSet: false,
isSetMandatory: false,
canAnnounceStatusChange: false,
isStatusChangeAnnouncementMandatory: false,
optionRequired: null,
description: null,
unit: null
Expand All @@ -61,12 +61,12 @@ internal static EchonetPropertySpecification CreateUnknown(byte code)
/// <param name="logicalDataType"><see cref="LogicalDataType"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="minSize"><see cref="MinSize"/>に設定する値。</param>
/// <param name="maxSize"><see cref="MaxSize"/>に設定する値。</param>
/// <param name="get"><see cref="Get"/>に設定する値。</param>
/// <param name="getRequired"><see cref="GetRequired"/>に設定する値。</param>
/// <param name="set"><see cref="Set"/>に設定する値。</param>
/// <param name="setRequired"><see cref="SetRequired"/>に設定する値。</param>
/// <param name="anno"><see cref="Anno"/>に設定する値。</param>
/// <param name="annoRequired"><see cref="AnnoRequired"/>に設定する値。</param>
/// <param name="canGet"><see cref="CanGet"/>に設定する値。</param>
/// <param name="isGetMandatory"><see cref="IsGetMandatory"/>に設定する値。</param>
/// <param name="canSet"><see cref="CanSet"/>に設定する値。</param>
/// <param name="isSetMandatory"><see cref="IsSetMandatory"/>に設定する値。</param>
/// <param name="canAnnounceStatusChange"><see cref="CanAnnounceStatusChange"/>に設定する値。</param>
/// <param name="isStatusChangeAnnouncementMandatory"><see cref="IsStatusChangeAnnouncementMandatory"/>に設定する値。</param>
/// <param name="optionRequired"><see cref="OptionRequired"/>に設定する値。 <see langword="null"/>が指定された場合は、空の<see cref="IReadOnlyList{ApplicationServiceName}"/>を設定します。</param>
/// <param name="description"><see cref="Description"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
/// <param name="unit"><see cref="Unit"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
Expand All @@ -83,12 +83,12 @@ public EchonetPropertySpecification
string? logicalDataType,
int? minSize,
int? maxSize,
bool get,
bool getRequired,
bool set,
bool setRequired,
bool anno,
bool annoRequired,
bool canGet,
bool isGetMandatory,
bool canSet,
bool isSetMandatory,
bool canAnnounceStatusChange,
bool isStatusChangeAnnouncementMandatory,
IReadOnlyList<ApplicationServiceName>? optionRequired,
string? description,
string? unit
Expand All @@ -102,12 +102,12 @@ public EchonetPropertySpecification
LogicalDataType = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(logicalDataType, nameof(logicalDataType));
MinSize = minSize;
MaxSize = maxSize;
Get = get;
GetRequired = getRequired;
Set = set;
SetRequired = setRequired;
Anno = anno;
AnnoRequired = annoRequired;
CanGet = canGet;
IsGetMandatory = isGetMandatory;
CanSet = canSet;
IsSetMandatory = isSetMandatory;
CanAnnounceStatusChange = canAnnounceStatusChange;
IsStatusChangeAnnouncementMandatory = isStatusChangeAnnouncementMandatory;
OptionRequired = optionRequired ?? Array.Empty<ApplicationServiceName>();
Description = string.IsNullOrEmpty(description) ? null : description;
Unit = string.IsNullOrEmpty(unit) ? null : unit;
Expand Down Expand Up @@ -168,14 +168,16 @@ public EchonetPropertySpecification
/// <seealso href="https://echonet.jp/spec_v114_lite/">
/// ECHONET Lite規格書 Ver.1.14 第2部 ECHONET Lite 通信ミドルウェア仕様 6.2.5 アクセスルール
/// </seealso>
/// <seealso cref="GetRequired"/>
public bool Get { get; }
/// <seealso cref="IsGetMandatory"/>
[JsonPropertyName("Get")]
public bool CanGet { get; }

/// <summary>
/// このプロパティとアクセスルール"Get"のサービスの実装が必須であるかどうかを表す値を取得します。
/// </summary>
/// <seealso cref="Get"/>
public bool GetRequired { get; }
/// <seealso cref="CanGet"/>
[JsonPropertyName("GetRequired")]
public bool IsGetMandatory { get; }

/// <summary>
/// アクセスルールに"Set"が規定されているかどうかを表す値を取得します。
Expand All @@ -187,14 +189,16 @@ public EchonetPropertySpecification
/// <seealso href="https://echonet.jp/spec_v114_lite/">
/// ECHONET Lite規格書 Ver.1.14 第2部 ECHONET Lite 通信ミドルウェア仕様 6.2.5 アクセスルール
/// </seealso>
/// <seealso cref="SetRequired"/>
public bool Set { get; }
/// <seealso cref="IsSetMandatory"/>
[JsonPropertyName("Set")]
public bool CanSet { get; }

/// <summary>
/// このプロパティとアクセスルール"Set"のサービスの実装が必須であるかどうかを表す値を取得します。
/// </summary>
/// <seealso cref="Set"/>
public bool SetRequired { get; }
/// <seealso cref="CanSet"/>
[JsonPropertyName("SetRequired")]
public bool IsSetMandatory { get; }

/// <summary>
/// アクセスルールに"Anno"が規定されているかどうかを表す値を取得します。
Expand All @@ -206,14 +210,16 @@ public EchonetPropertySpecification
/// <seealso href="https://echonet.jp/spec_v114_lite/">
/// ECHONET Lite規格書 Ver.1.14 第2部 ECHONET Lite 通信ミドルウェア仕様 6.2.5 アクセスルール
/// </seealso>
/// <seealso cref="AnnoRequired"/>
public bool Anno { get; }
/// <seealso cref="IsStatusChangeAnnouncementMandatory"/>
[JsonPropertyName("Anno")]
public bool CanAnnounceStatusChange { get; }

/// <summary>
/// このプロパティとアクセスルール"Anno"のサービスの実装が必須であるかどうかを表す値を取得します。
/// </summary>
/// <seealso cref="Anno"/>
public bool AnnoRequired { get; }
/// <seealso cref="CanAnnounceStatusChange"/>
[JsonPropertyName("AnnoRequired")]
public bool IsStatusChangeAnnouncementMandatory { get; }

/// <summary>
/// アプリケーションサービスの「オプション必須」プロパティ表記
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ internal void ResetProperties(IEnumerable<EchonetProperty> props)
/// <summary>
/// GETプロパティの一覧
/// </summary>
public IEnumerable<EchonetProperty> GetProperties => Properties.Where(static p => p.Spec.Get);
public IEnumerable<EchonetProperty> GetProperties => Properties.Where(static p => p.Spec.CanGet);

/// <summary>
/// SETプロパティの一覧
/// </summary>
public IEnumerable<EchonetProperty> SetProperties => Properties.Where(static p => p.Spec.Set);
public IEnumerable<EchonetProperty> SetProperties => Properties.Where(static p => p.Spec.CanSet);

/// <summary>
/// ANNOプロパティの一覧
/// </summary>
public IEnumerable<EchonetProperty> AnnoProperties => Properties.Where(static p => p.Spec.Anno);
public IEnumerable<EchonetProperty> AnnoProperties => Properties.Where(static p => p.Spec.CanAnnounceStatusChange);
}
}
42 changes: 21 additions & 21 deletions src/Smdn.Net.EchonetLite/Smdn.Net.EchonetLite/EchonetProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ byte epc
classGroupCode: classGroupCode,
classCode: classCode,
epc: epc,
isAnno: false,
isSet: false,
isGet: false
canAnnounceStatusChange: false,
canSet: false,
canGet: false
)
{
}
Expand All @@ -37,16 +37,16 @@ public EchonetProperty
byte classGroupCode,
byte classCode,
byte epc,
bool isAnno,
bool isSet,
bool isGet
bool canAnnounceStatusChange,
bool canSet,
bool canGet
)
: this
(
spec: DeviceClasses.LookupOrCreateProperty(classGroupCode, classCode, epc, includeProfiles: true),
isAnno: isAnno,
isSet: isSet,
isGet: isGet
canAnnounceStatusChange: canAnnounceStatusChange,
canSet: canSet,
canGet: canGet
)
{
}
Expand All @@ -55,25 +55,25 @@ public EchonetProperty(EchonetPropertySpecification spec)
: this
(
spec: spec,
isAnno: false,
isSet: false,
isGet: false
canAnnounceStatusChange: false,
canSet: false,
canGet: false
)
{
}

public EchonetProperty
(
EchonetPropertySpecification spec,
bool isAnno,
bool isSet,
bool isGet
bool canAnnounceStatusChange,
bool canSet,
bool canGet
)
{
Spec = spec ?? throw new ArgumentNullException(nameof(spec));
IsAnno = isAnno;
IsSet = isSet;
IsGet = isGet;
CanAnnounceStatusChange = canAnnounceStatusChange;
CanSet = canSet;
CanGet = canGet;
}

/// <summary>
Expand All @@ -85,17 +85,17 @@ bool isGet
/// プロパティ値の読み出し・通知要求のサービスを処理する。
/// プロパティ値読み出し要求(0x62)、プロパティ値書き込み・読み出し要求(0x6E)、プロパティ値通知要求(0x63)の要求受付処理を実施する。
/// </summary>
public bool IsGet { get; }
public bool CanGet { get; }
/// <summary>
/// プロパティ値の書き込み要求のサービスを処理する。
/// プロパティ値書き込み要求(応答不要)(0x60)、プロパティ値書き込み要求(応答要)(0x61)、プロパティ値書き込み・読み出し要求(0x6E)の要求受付処理を実施する。
/// </summary>
public bool IsSet { get; }
public bool CanSet { get; }
/// <summary>
/// プロパティ値の通知要求のサービスを処理する。
/// プロパティ値通知要求(0x63)の要求受付処理を実施する。
/// </summary>
public bool IsAnno { get; }
public bool CanAnnounceStatusChange { get; }

private ArrayBufferWriter<byte>? _value = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public static string GetDebugString(this EchonetProperty property)
sb.AppendFormat(provider: null, "0x{0:X2}", property.Spec.Code);
sb.Append(property.Spec.Name);
sb.Append(' ');
sb.Append(property.IsGet ? "Get" : "");
sb.Append(property.Spec.GetRequired ? "(Req)" : "");
sb.Append(property.CanGet ? "Get" : "");
sb.Append(property.Spec.IsGetMandatory ? "(Req)" : "");
sb.Append(' ');
sb.Append(property.IsSet ? "Set" : "");
sb.Append(property.Spec.SetRequired ? "(Req)" : "");
sb.Append(property.CanSet ? "Set" : "");
sb.Append(property.Spec.IsSetMandatory ? "(Req)" : "");
sb.Append(' ');
sb.Append(property.IsAnno ? "Anno" : "");
sb.Append(property.Spec.AnnoRequired ? "(Req)" : "");
sb.Append(property.CanAnnounceStatusChange ? "Anno" : "");
sb.Append(property.Spec.IsStatusChangeAnnouncementMandatory ? "(Req)" : "");
return sb.ToString();
}
}
Expand Down
Loading

0 comments on commit e0bbb71

Please sign in to comment.