Skip to content

Commit

Permalink
fix code format
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed Apr 2, 2024
1 parent bb9c8cd commit a1eba23
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public sealed class EchonetClassGroupSpecification {
[JsonPropertyName("ClassGroupCode")]
[JsonConverter(typeof(SingleByteHexStringJsonConverter))]
public byte Code { get; }

/// <summary>
/// クラスグループ名
/// </summary>
Expand All @@ -60,6 +61,7 @@ public sealed class EchonetClassGroupSpecification {
/// </summary>
[JsonPropertyName("SuperClass")]
public string? SuperClassName { get; }

/// <summary>
/// クラスグループに属するクラスのリスト
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ public sealed class EchonetClassSpecification {
/// </summary>
[JsonPropertyName("Status")]
public bool IsDefined { get; }

/// <summary>
/// クラスコード
/// </summary>
[JsonPropertyName("ClassCode")]
[JsonConverter(typeof(SingleByteHexStringJsonConverter))]
public byte Code { get; }

/// <summary>
/// クラス名
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ IReadOnlyList<EchonetPropertySpecification> Properties
/// クラスグループコード
/// </summary>
public EchonetClassGroupSpecification ClassGroup { get; }

/// <summary>
/// クラス情報
/// クラスコード
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,39 @@ internal static EchonetPropertySpecification CreateUnknown(byte code)
/// プロパティ名称
/// </summary>
public string Name { get; }

/// <summary>
/// EPC(ECHONET プロパティコード)
/// </summary>
[JsonConverter(typeof(SingleByteHexStringJsonConverter))]
public byte Code { get; }

/// <summary>
/// プロパティ内容
/// </summary>
public string Detail { get; }

/// <summary>
/// 値域(10 進表記)
/// </summary>
[JsonPropertyName("Value")]
public string? ValueRange { get; }

/// <summary>
/// データ型
/// </summary>
public string DataType { get; }

/// <summary>
/// C#論理データ型
/// </summary>
public string LogicalDataType { get; }

/// <summary>
/// 最小サイズ
/// </summary>
public int? MinSize { get; }

/// <summary>
/// 最大サイズ
/// </summary>
Expand Down Expand Up @@ -223,10 +230,12 @@ internal static EchonetPropertySpecification CreateUnknown(byte code)
// MasterDataのJSONファイルでは、プロパティ名がOptionRequiredではなくOptionRequierdとなっていることに注意
[JsonPropertyName("OptionRequierd")]
public IReadOnlyList<ApplicationServiceName> OptionRequired { get; }

/// <summary>
/// 備考
/// </summary>
public string? Description { get; }

/// <summary>
/// 単位
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ internal sealed class PropertyMaster {
/// ECHONET Lite SPECIFICATIONのバージョン
/// </summary>
public string Version { get; }

/// <summary>
/// APPENDIX ECHONET 機器オブジェクト詳細規定のリリース番号
/// </summary>
public string AppendixRelease { get; }

/// <summary>
/// プロパティのリスト
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ private sealed class SpecificationMasterJsonObject {
/// ECHONET Lite SPECIFICATIONのバージョン
/// </summary>
public string Version { get; }

/// <summary>
/// APPENDIX ECHONET 機器オブジェクト詳細規定のリリース番号
/// </summary>
public string AppendixRelease { get; }

/// <summary>
/// プロファイルオブジェクト
/// </summary>
[JsonPropertyName("プロファイル")]
public IReadOnlyList<EchonetClassGroupSpecification> Profiles { get; }

/// <summary>
/// 機器オブジェクト
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ public enum ApplicationServiceName {
/// モバイルサービス(Mobile services)○M
/// </summary>
MobileServices,

/// <summary>
/// エネルギーサービス(Energy services)○E
/// </summary>
EnergyServices,

/// <summary>
/// 快適生活支援サービス(Home amenity services)○Ha
/// </summary>
HomeAmenityServices,

/// <summary>
/// ホームヘルスケアサービス(Home health-care services)○Hh
/// </summary>
HomeHealthcareServices,

/// <summary>
/// セキュリティサービス(Security services)○S
/// </summary>
SecurityServices,

/// <summary>
/// 機器リモートメンテナンスサービス(Remote appliance maintenance services)○R
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ bool includeProfiles
AV関連機器.ネットワークカメラ,
Profiles.NodeProfile,
];

/// <summary>
/// ECHONET Lite クラスグループ定義
/// センサ関連機器クラスグループ
Expand Down Expand Up @@ -410,6 +411,7 @@ public static class センサ関連機器 {
/// </summary>
public static EchonetObjectSpecification 気圧センサ { get; } = new(0x00, 0x2D);
}

/// <summary>
/// ECHONET Lite クラスグループ定義
/// 空調関連機器 クラスグループ
Expand Down Expand Up @@ -464,6 +466,7 @@ public static class 空調関連機器 {
/// </summary>
public static EchonetObjectSpecification 業務用ガスヒートポンプエアコン室外機 { get; } = new(0x01, 0x59);
}

/// <summary>
/// ECHONET Lite クラスグループ定義
/// 住宅設備関連機器クラスグループ
Expand Down Expand Up @@ -618,6 +621,7 @@ public static class 住宅設備関連機器 {
/// </summary>
public static EchonetObjectSpecification マルチ入力PCS { get; } = new(0x02, 0xA5);
}

/// <summary>
/// ECHONET Lite クラスグループ定義
/// 調理家事関連機器 クラスグループ
Expand Down Expand Up @@ -675,6 +679,7 @@ public static class 健康関連機器 {
/// </summary>
public static EchonetObjectSpecification 体重計 { get; } = new(0x04, 0x01);
}

/// <summary>
/// ECHONET Lite クラスグループ定義
/// 管理操作関連機器 クラスグループ
Expand All @@ -701,6 +706,7 @@ public static class 管理操作関連機器 {
/// </summary>
public static EchonetObjectSpecification コントローラ { get; } = new(0x05, 0xFF);
}

/// <summary>
/// ECHONET Lite クラスグループ定義
/// AV関連機器 クラスグループ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ public EData1(EOJ seoj, EOJ deoj, ESV esv, IReadOnlyCollection<PropertyRequest>
/// 送信元ECHONET Liteオブジェクト指定(3B)
/// </summary>
public EOJ SEOJ { get; }

/// <summary>
/// 相手先ECHONET Liteオブジェクト指定(3B)
/// </summary>
public EOJ DEOJ { get; }

/// <summary>
/// ECHONET Liteサービス(1B)
/// ECHONET Liteサービスコード
Expand All @@ -87,11 +89,13 @@ public EData1(EOJ seoj, EOJ deoj, ESV esv, IReadOnlyCollection<PropertyRequest>
public ESV ESV { get; }

public IReadOnlyCollection<PropertyRequest>? OPCList { get; }

/// <summary>
/// 4.2.3.4 プロパティ値書き込み読み出しサービス[0x6E,0x7E,0x5E]
/// のみ使用
/// </summary>
public IReadOnlyCollection<PropertyRequest>? OPCGetList { get; }

/// <summary>
/// 4.2.3.4 プロパティ値書き込み読み出しサービス[0x6E,0x7E,0x5E]
/// のみ使用
Expand Down
46 changes: 21 additions & 25 deletions src/Smdn.Net.EchonetLite/Smdn.Net.EchonetLite.Protocol/EOJ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,48 +30,44 @@ public EOJ(byte classGroupCode, byte classCode, byte instanceCode)
/// </summary>
[JsonConverter(typeof(SingleByteJsonConverterFactory))]
public byte ClassGroupCode { get; }

/// <summary>
/// クラスクラスコード
/// </summary>
[JsonConverter(typeof(SingleByteJsonConverterFactory))]
public byte ClassCode { get; }

/// <summary>
/// インスタンスコード
/// </summary>
[JsonConverter(typeof(SingleByteJsonConverterFactory))]
public byte InstanceCode { get; }

public bool Equals(EOJ other)
{
return ClassGroupCode == other.ClassGroupCode
&& ClassCode == other.ClassCode
&& InstanceCode == other.InstanceCode;
}
=>
ClassGroupCode == other.ClassGroupCode &&
ClassCode == other.ClassCode &&
InstanceCode == other.InstanceCode;

public override bool Equals(object? other)
{
if (other is null)
return false;
if (other is EOJ)
return Equals((EOJ)other);
return false;
}
=> other switch {
EOJ otherEOJ => Equals(otherEOJ),
null => false,
_ => false
};

public override int GetHashCode()
{
return ClassGroupCode.GetHashCode()
^ ClassCode.GetHashCode()
^ InstanceCode.GetHashCode();
}
=>
ClassGroupCode.GetHashCode() ^
ClassCode.GetHashCode() ^
InstanceCode.GetHashCode();

public static bool operator ==(EOJ c1, EOJ c2)
{
return c1.ClassGroupCode == c2.ClassGroupCode
&& c1.ClassCode == c2.ClassCode
&& c1.InstanceCode == c2.InstanceCode;
}
=>
c1.ClassGroupCode == c2.ClassGroupCode &&
c1.ClassCode == c2.ClassCode &&
c1.InstanceCode == c2.InstanceCode;

public static bool operator !=(EOJ c1, EOJ c2)
{
return !(c1 == c2);
}
=> !(c1 == c2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ public Frame(EHD1 ehd1, EHD2 ehd2, ushort tid, IEData edata)
/// </summary>
[JsonConverter(typeof(SingleByteJsonConverterFactory))]
public EHD1 EHD1 { get; }

/// <summary>
/// ECHONET Lite電文ヘッダー2(1B)
/// EDATA部の電文形式を指定する。
/// </summary>
[JsonConverter(typeof(SingleByteJsonConverterFactory))]
public EHD2 EHD2 { get; }

/// <summary>
/// トランザクションID(2B)
/// </summary>
[JsonConverter(typeof(SingleUInt16JsonConverter))]
public ushort TID { get; }

/// <summary>
/// ECHONET Liteデータ
/// ECHONET Lite 通信ミドルウェアにてやり取りされる電文のデータ領域。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ public static void Serialize(Frame frame, IBufferWriter<byte> buffer)
if (frame.EData is not EData1 edata1)
throw new ArgumentException($"{nameof(EData1)} must be set to {nameof(Frame)}.{nameof(Frame.EData)}.", paramName: nameof(frame));

#if !NET5_0_OR_GREATER // NotNullWhenAttribute
#pragma warning disable CS8604
#endif
SerializeEchonetLiteFrameFormat1(
buffer,
frame.TID,
edata1.SEOJ,
edata1.DEOJ,
edata1.ESV,
edata1.IsWriteOrReadService ? edata1.OPCSetList : edata1.OPCList,
edata1.IsWriteOrReadService ? edata1.OPCSetList! : edata1.OPCList!,
edata1.IsWriteOrReadService ? edata1.OPCGetList : null
);
#pragma warning restore CS8604

break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
// SPDX-License-Identifier: MIT
namespace Smdn.Net.EchonetLite.Protocol;

public interface IEData {
}
public interface IEData { }
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public PropertyRequest(byte epc, ReadOnlyMemory<byte> edt)
/// </summary>
[JsonConverter(typeof(SingleByteJsonConverterFactory))]
public byte EPC { get; }

/// <summary>
/// EDTのバイト数(1B)
/// </summary>
[JsonConverter(typeof(SingleByteJsonConverterFactory))]
public byte PDC => (byte)EDT.Length;

/// <summary>
/// プロパティ値データ(PDCで指定)
/// </summary>
Expand Down
Loading

0 comments on commit a1eba23

Please sign in to comment.