diff --git a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite.Appendix/EchonetObjectSpecification.cs b/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite.Appendix/EchonetObjectSpecification.cs index 3e2af1f..4fcc89f 100644 --- a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite.Appendix/EchonetObjectSpecification.cs +++ b/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite.Appendix/EchonetObjectSpecification.cs @@ -8,9 +8,33 @@ namespace Smdn.Net.EchonetLite.Appendix { - internal class EchonetObjectSpecification : IEchonetObject + /// + /// ECHONET Lite オブジェクト + /// + public sealed class EchonetObjectSpecification { - public EchonetObjectSpecification(byte classGroupCode, byte classCode) + /// + /// 指定されたクラスグループコード・クラスコードをもつ、未知のECHONET Lite オブジェクトを作成します。 + /// + internal static EchonetObjectSpecification CreateUnknown(byte classGroupCode, byte classCode) + => new( + classGroup: new( + code: classGroupCode, + name: "Unknown", + propertyName: "Unknown", + classes: Array.Empty(), + superClassName: null + ), + @class: new( + isDefined: false, + code: classCode, + name: "Unknown", + propertyName: "Unknown" + ), + properties: Array.Empty() + ); + + internal EchonetObjectSpecification(byte classGroupCode, byte classCode) { ClassGroup = SpecificationMaster.GetInstance().プロファイル.FirstOrDefault(p => p.Code == classGroupCode) ?? @@ -47,11 +71,25 @@ public EchonetObjectSpecification(byte classGroupCode, byte classCode) Properties = properties; } + + private EchonetObjectSpecification( + EchonetClassGroupSpecification classGroup, + EchonetClassSpecification @class, + IReadOnlyList properties + ) + { + ClassGroup = classGroup; + Class = @class; + Properties = properties; + } + /// + /// クラスグループ情報 /// クラスグループコード /// public EchonetClassGroupSpecification ClassGroup { get; } /// + /// クラス情報 /// クラスコード /// public EchonetClassSpecification Class { get; } diff --git a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs b/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs index a6587d2..8ef54c6 100644 --- a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs +++ b/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2018 HiroyukiSakoh // SPDX-FileCopyrightText: 2023 smdn // SPDX-License-Identifier: MIT -using System; using System.Collections.Generic; #if NULL_STATE_STATIC_ANALYSIS_ATTRIBUTES using System.Diagnostics.CodeAnalysis; @@ -34,7 +33,7 @@ public static bool TryLookupClass( #if NULL_STATE_STATIC_ANALYSIS_ATTRIBUTES [NotNullWhen(true)] #endif - out IEchonetObject? echonetObject + out EchonetObjectSpecification? echonetObject ) { echonetObject = default; @@ -65,7 +64,7 @@ out IEchonetObject? echonetObject /// 一致するECHONET Lite オブジェクトを取得できた場合は、そのオブジェクトを返します。 /// 一致するECHONET Lite オブジェクトが存在しない場合は、指定されたクラスグループコード・クラスコードをもつオブジェクトを作成して返します。 /// - public static IEchonetObject LookupClass( + public static EchonetObjectSpecification LookupClass( byte classGroupCode, byte classCode, bool includeProfiles @@ -76,57 +75,13 @@ bool includeProfiles #if !NULL_STATE_STATIC_ANALYSIS_ATTRIBUTES ! #endif - : GenerateUnknownClass(classGroupCode, classCode); - - /// - /// 指定されたクラスグループコード・クラスコードをもつ、未知のECHONET Lite オブジェクトを作成します。 - /// - /// 作成するECHONET Lite オブジェクトのクラスグループコード。 - /// 作成するECHONET Lite オブジェクトのクラスコード。 - /// 作成したECHONET Lite オブジェクト。 - private static UnknownEchoObject GenerateUnknownClass(byte classGroupCode, byte classCode) - => new - ( - classGroup: new - ( - code: classGroupCode, - name: "Unknown", - propertyName: "Unknown", - classes: Array.Empty(), - superClassName: null - ), - @class: new - ( - isDefined: false, - code: classCode, - name: "Unknown", - propertyName: "Unknown" - ) - ); - - private class UnknownEchoObject : IEchonetObject - { - public UnknownEchoObject(EchonetClassGroupSpecification classGroup, EchonetClassSpecification @class) - { - ClassGroup = classGroup ?? throw new ArgumentNullException(nameof(classGroup)); - Class = @class ?? throw new ArgumentNullException(nameof(@class)); - } - - public EchonetClassGroupSpecification ClassGroup { get; } - public EchonetClassSpecification Class { get; } - - public IEnumerable GetProperties => Enumerable.Empty(); - - public IEnumerable SetProperties => Enumerable.Empty(); - - public IEnumerable AnnoProperties => Enumerable.Empty(); - } + : EchonetObjectSpecification.CreateUnknown(classGroupCode, classCode); /// /// 一覧 /// - public static IReadOnlyList All { get; } = new IEchonetObject[] - { + public static IReadOnlyList All { get; } = + [ センサ関連機器.ガス漏れセンサ, センサ関連機器.防犯センサ, センサ関連機器.非常ボタン, @@ -241,7 +196,7 @@ public UnknownEchoObject(EchonetClassGroupSpecification classGroup, EchonetClass AV関連機器.オーディオ, AV関連機器.ネットワークカメラ, Profiles.NodeProfile, - }; + ]; /// /// ECHONET Lite クラスグループ定義 /// センサ関連機器クラスグループ @@ -251,180 +206,180 @@ public static class センサ関連機器 /// /// 0x01 ガス漏れセンサ /// - public static IEchonetObject ガス漏れセンサ { get; } = new EchonetObjectSpecification(0x00, 0x01); + public static EchonetObjectSpecification ガス漏れセンサ { get; } = new(0x00, 0x01); /// /// 0x02 防犯センサ /// - public static IEchonetObject 防犯センサ { get; } = new EchonetObjectSpecification(0x00, 0x02); + public static EchonetObjectSpecification 防犯センサ { get; } = new(0x00, 0x02); /// /// 0x03 非常ボタン /// - public static IEchonetObject 非常ボタン { get; } = new EchonetObjectSpecification(0x00, 0x03); + public static EchonetObjectSpecification 非常ボタン { get; } = new(0x00, 0x03); /// /// 0x04 救急用センサ /// - public static IEchonetObject 救急用センサ { get; } = new EchonetObjectSpecification(0x00, 0x04); + public static EchonetObjectSpecification 救急用センサ { get; } = new(0x00, 0x04); /// /// 0x05 地震センサ /// - public static IEchonetObject 地震センサ { get; } = new EchonetObjectSpecification(0x00, 0x05); + public static EchonetObjectSpecification 地震センサ { get; } = new(0x00, 0x05); /// /// 0x06 漏電センサ /// - public static IEchonetObject 漏電センサ { get; } = new EchonetObjectSpecification(0x00, 0x06); + public static EchonetObjectSpecification 漏電センサ { get; } = new(0x00, 0x06); /// /// 0x07 人体検知センサ /// - public static IEchonetObject 人体検知センサ { get; } = new EchonetObjectSpecification(0x00, 0x07); + public static EchonetObjectSpecification 人体検知センサ { get; } = new(0x00, 0x07); /// /// 0x08 来客センサ /// - public static IEchonetObject 来客センサ { get; } = new EchonetObjectSpecification(0x00, 0x08); + public static EchonetObjectSpecification 来客センサ { get; } = new(0x00, 0x08); /// /// 0x09 呼び出しセンサ /// - public static IEchonetObject 呼び出しセンサ { get; } = new EchonetObjectSpecification(0x00, 0x09); + public static EchonetObjectSpecification 呼び出しセンサ { get; } = new(0x00, 0x09); /// /// 0x0A 結露センサ /// - public static IEchonetObject 結露センサ { get; } = new EchonetObjectSpecification(0x00, 0x0A); + public static EchonetObjectSpecification 結露センサ { get; } = new(0x00, 0x0A); /// /// 0x0B 空気汚染センサ /// - public static IEchonetObject 空気汚染センサ { get; } = new EchonetObjectSpecification(0x00, 0x0B); + public static EchonetObjectSpecification 空気汚染センサ { get; } = new(0x00, 0x0B); /// /// 0x0C 酸素センサ /// - public static IEchonetObject 酸素センサ { get; } = new EchonetObjectSpecification(0x00, 0x0C); + public static EchonetObjectSpecification 酸素センサ { get; } = new(0x00, 0x0C); /// /// 0x0D 照度センサ /// - public static IEchonetObject 照度センサ { get; } = new EchonetObjectSpecification(0x00, 0x0D); + public static EchonetObjectSpecification 照度センサ { get; } = new(0x00, 0x0D); /// /// 0x0E 音センサ /// - public static IEchonetObject 音センサ { get; } = new EchonetObjectSpecification(0x00, 0x0E); + public static EchonetObjectSpecification 音センサ { get; } = new(0x00, 0x0E); /// /// 0x0F 投函センサ /// - public static IEchonetObject 投函センサ { get; } = new EchonetObjectSpecification(0x00, 0x0F); + public static EchonetObjectSpecification 投函センサ { get; } = new(0x00, 0x0F); /// /// 0x10 重荷センサ /// - public static IEchonetObject 重荷センサ { get; } = new EchonetObjectSpecification(0x00, 0x10); + public static EchonetObjectSpecification 重荷センサ { get; } = new(0x00, 0x10); /// /// 0x11 温度センサ /// - public static IEchonetObject 温度センサ { get; } = new EchonetObjectSpecification(0x00, 0x11); + public static EchonetObjectSpecification 温度センサ { get; } = new(0x00, 0x11); /// /// 0x12 湿度センサ /// - public static IEchonetObject 湿度センサ { get; } = new EchonetObjectSpecification(0x00, 0x12); + public static EchonetObjectSpecification 湿度センサ { get; } = new(0x00, 0x12); /// /// 0x13 雨センサ /// - public static IEchonetObject 雨センサ { get; } = new EchonetObjectSpecification(0x00, 0x13); + public static EchonetObjectSpecification 雨センサ { get; } = new(0x00, 0x13); /// /// 0x14 水位センサ /// - public static IEchonetObject 水位センサ { get; } = new EchonetObjectSpecification(0x00, 0x14); + public static EchonetObjectSpecification 水位センサ { get; } = new(0x00, 0x14); /// /// 0x15 風呂水位センサ /// - public static IEchonetObject 風呂水位センサ { get; } = new EchonetObjectSpecification(0x00, 0x15); + public static EchonetObjectSpecification 風呂水位センサ { get; } = new(0x00, 0x15); /// /// 0x16 風呂沸き上がりセンサ /// - public static IEchonetObject 風呂沸き上がりセンサ { get; } = new EchonetObjectSpecification(0x00, 0x16); + public static EchonetObjectSpecification 風呂沸き上がりセンサ { get; } = new(0x00, 0x16); /// /// 0x17 水漏れセンサ /// - public static IEchonetObject 水漏れセンサ { get; } = new EchonetObjectSpecification(0x00, 0x17); + public static EchonetObjectSpecification 水漏れセンサ { get; } = new(0x00, 0x17); /// /// 0x18 水あふれセンサ /// - public static IEchonetObject 水あふれセンサ { get; } = new EchonetObjectSpecification(0x00, 0x18); + public static EchonetObjectSpecification 水あふれセンサ { get; } = new(0x00, 0x18); /// /// 0x19 火災センサ /// - public static IEchonetObject 火災センサ { get; } = new EchonetObjectSpecification(0x00, 0x19); + public static EchonetObjectSpecification 火災センサ { get; } = new(0x00, 0x19); /// /// 0x1A タバコ煙センサ /// - public static IEchonetObject タバコ煙センサ { get; } = new EchonetObjectSpecification(0x00, 0x1A); + public static EchonetObjectSpecification タバコ煙センサ { get; } = new(0x00, 0x1A); /// /// 0x1B CO2センサ /// - public static IEchonetObject CO2センサ { get; } = new EchonetObjectSpecification(0x00, 0x1B); + public static EchonetObjectSpecification CO2センサ { get; } = new(0x00, 0x1B); /// /// 0x1C ガスセンサ /// - public static IEchonetObject ガスセンサ { get; } = new EchonetObjectSpecification(0x00, 0x1C); + public static EchonetObjectSpecification ガスセンサ { get; } = new(0x00, 0x1C); /// /// 0x1D VOCセンサ /// - public static IEchonetObject VOCセンサ { get; } = new EchonetObjectSpecification(0x00, 0x1D); + public static EchonetObjectSpecification VOCセンサ { get; } = new(0x00, 0x1D); /// /// 0x1E 差圧センサ /// - public static IEchonetObject 差圧センサ { get; } = new EchonetObjectSpecification(0x00, 0x1E); + public static EchonetObjectSpecification 差圧センサ { get; } = new(0x00, 0x1E); /// /// 0x1F 風速センサ /// - public static IEchonetObject 風速センサ { get; } = new EchonetObjectSpecification(0x00, 0x1F); + public static EchonetObjectSpecification 風速センサ { get; } = new(0x00, 0x1F); /// /// 0x20 臭いセンサ /// - public static IEchonetObject 臭いセンサ { get; } = new EchonetObjectSpecification(0x00, 0x20); + public static EchonetObjectSpecification 臭いセンサ { get; } = new(0x00, 0x20); /// /// 0x21 炎センサ /// - public static IEchonetObject 炎センサ { get; } = new EchonetObjectSpecification(0x00, 0x21); + public static EchonetObjectSpecification 炎センサ { get; } = new(0x00, 0x21); /// /// 0x22 電力量センサ /// - public static IEchonetObject 電力量センサ { get; } = new EchonetObjectSpecification(0x00, 0x22); + public static EchonetObjectSpecification 電力量センサ { get; } = new(0x00, 0x22); /// /// 0x23 電流量センサ /// - public static IEchonetObject 電流量センサ { get; } = new EchonetObjectSpecification(0x00, 0x23); + public static EchonetObjectSpecification 電流量センサ { get; } = new(0x00, 0x23); /// /// 0x25 水流量センサ /// - public static IEchonetObject 水流量センサ { get; } = new EchonetObjectSpecification(0x00, 0x25); + public static EchonetObjectSpecification 水流量センサ { get; } = new(0x00, 0x25); /// /// 0x26 微動センサ /// - public static IEchonetObject 微動センサ { get; } = new EchonetObjectSpecification(0x00, 0x26); + public static EchonetObjectSpecification 微動センサ { get; } = new(0x00, 0x26); /// /// 0x27 通過センサ /// - public static IEchonetObject 通過センサ { get; } = new EchonetObjectSpecification(0x00, 0x27); + public static EchonetObjectSpecification 通過センサ { get; } = new(0x00, 0x27); /// /// 0x28 在床センサ /// - public static IEchonetObject 在床センサ { get; } = new EchonetObjectSpecification(0x00, 0x28); + public static EchonetObjectSpecification 在床センサ { get; } = new(0x00, 0x28); /// /// 0x29 開閉センサ /// - public static IEchonetObject 開閉センサ { get; } = new EchonetObjectSpecification(0x00, 0x29); + public static EchonetObjectSpecification 開閉センサ { get; } = new(0x00, 0x29); /// /// 0x2A 活動量センサ /// - public static IEchonetObject 活動量センサ { get; } = new EchonetObjectSpecification(0x00, 0x2A); + public static EchonetObjectSpecification 活動量センサ { get; } = new(0x00, 0x2A); /// /// 0x2B 人体位置センサ /// - public static IEchonetObject 人体位置センサ { get; } = new EchonetObjectSpecification(0x00, 0x2B); + public static EchonetObjectSpecification 人体位置センサ { get; } = new(0x00, 0x2B); /// /// 0x2C 雪センサ /// - public static IEchonetObject 雪センサ { get; } = new EchonetObjectSpecification(0x00, 0x2C); + public static EchonetObjectSpecification 雪センサ { get; } = new(0x00, 0x2C); /// /// 0x2D 気圧センサ /// - public static IEchonetObject 気圧センサ { get; } = new EchonetObjectSpecification(0x00, 0x2D); + public static EchonetObjectSpecification 気圧センサ { get; } = new(0x00, 0x2D); } /// /// ECHONET Lite クラスグループ定義 @@ -435,51 +390,51 @@ public static class 空調関連機器 /// /// 0x30 家庭用エアコン /// - public static IEchonetObject 家庭用エアコン { get; } = new EchonetObjectSpecification(0x01, 0x30); + public static EchonetObjectSpecification 家庭用エアコン { get; } = new(0x01, 0x30); /// /// 0x33 換気扇 /// - public static IEchonetObject 換気扇 { get; } = new EchonetObjectSpecification(0x01, 0x33); + public static EchonetObjectSpecification 換気扇 { get; } = new(0x01, 0x33); /// /// 0x34 空調換気扇 /// - public static IEchonetObject 空調換気扇 { get; } = new EchonetObjectSpecification(0x01, 0x34); + public static EchonetObjectSpecification 空調換気扇 { get; } = new(0x01, 0x34); /// /// 0x35 空気清浄器 /// - public static IEchonetObject 空気清浄器 { get; } = new EchonetObjectSpecification(0x01, 0x35); + public static EchonetObjectSpecification 空気清浄器 { get; } = new(0x01, 0x35); /// /// 0x39 加湿器 /// - public static IEchonetObject 加湿器 { get; } = new EchonetObjectSpecification(0x01, 0x39); + public static EchonetObjectSpecification 加湿器 { get; } = new(0x01, 0x39); /// /// 0x42 電気暖房器 /// - public static IEchonetObject 電気暖房器 { get; } = new EchonetObjectSpecification(0x01, 0x42); + public static EchonetObjectSpecification 電気暖房器 { get; } = new(0x01, 0x42); /// /// 0x43 ファンヒータ /// - public static IEchonetObject ファンヒータ { get; } = new EchonetObjectSpecification(0x01, 0x43); + public static EchonetObjectSpecification ファンヒータ { get; } = new(0x01, 0x43); /// /// 0x55 電気蓄熱暖房器 /// - public static IEchonetObject 電気蓄熱暖房器 { get; } = new EchonetObjectSpecification(0x01, 0x55); + public static EchonetObjectSpecification 電気蓄熱暖房器 { get; } = new(0x01, 0x55); /// /// 0x56 業務用パッケージエアコン室内機(設備用除く) /// - public static IEchonetObject 業務用パッケージエアコン室内機設備用除く { get; } = new EchonetObjectSpecification(0x01, 0x56); + public static EchonetObjectSpecification 業務用パッケージエアコン室内機設備用除く { get; } = new(0x01, 0x56); /// /// 0x57 業務用パッケージエアコン室外機(設備用除く) /// - public static IEchonetObject 業務用パッケージエアコン室外機設備用除く { get; } = new EchonetObjectSpecification(0x01, 0x57); + public static EchonetObjectSpecification 業務用パッケージエアコン室外機設備用除く { get; } = new(0x01, 0x57); /// - /// 0x58 業務用ガスヒートポンプエアコン室内機 + /// 0x58 業務用ガスヒートポンプエアコン室内機 /// - public static IEchonetObject 業務用ガスヒートポンプエアコン室内機 { get; } = new EchonetObjectSpecification(0x01, 0x58); + public static EchonetObjectSpecification 業務用ガスヒートポンプエアコン室内機 { get; } = new(0x01, 0x58); /// - /// 0x59 業務用ガスヒートポンプエアコン室外機 + /// 0x59 業務用ガスヒートポンプエアコン室外機 /// - public static IEchonetObject 業務用ガスヒートポンプエアコン室外機 { get; } = new EchonetObjectSpecification(0x01, 0x59); + public static EchonetObjectSpecification 業務用ガスヒートポンプエアコン室外機 { get; } = new(0x01, 0x59); } /// /// ECHONET Lite クラスグループ定義 @@ -490,151 +445,151 @@ public static class 住宅設備関連機器 /// /// 0x60 電動ブラインド・日よけ /// - public static IEchonetObject 電動ブラインド日よけ { get; } = new EchonetObjectSpecification(0x02, 0x60); + public static EchonetObjectSpecification 電動ブラインド日よけ { get; } = new(0x02, 0x60); /// /// 0x61 電動シャッター /// - public static IEchonetObject 電動シャッター { get; } = new EchonetObjectSpecification(0x02, 0x61); + public static EchonetObjectSpecification 電動シャッター { get; } = new(0x02, 0x61); /// /// 0x63 電動雨戸・シャッター /// - public static IEchonetObject 電動雨戸シャッター { get; } = new EchonetObjectSpecification(0x02, 0x63); + public static EchonetObjectSpecification 電動雨戸シャッター { get; } = new(0x02, 0x63); /// /// 0x64 電動ゲート /// - public static IEchonetObject 電動ゲート { get; } = new EchonetObjectSpecification(0x02, 0x64); + public static EchonetObjectSpecification 電動ゲート { get; } = new(0x02, 0x64); /// /// 0x65 電動窓 /// - public static IEchonetObject 電動窓 { get; } = new EchonetObjectSpecification(0x02, 0x65); + public static EchonetObjectSpecification 電動窓 { get; } = new(0x02, 0x65); /// /// 0x66 電動玄関ドア・引戸 /// - public static IEchonetObject 電動玄関ドア引戸 { get; } = new EchonetObjectSpecification(0x02, 0x66); + public static EchonetObjectSpecification 電動玄関ドア引戸 { get; } = new(0x02, 0x66); /// /// 0x67 散水器(庭用) /// - public static IEchonetObject 散水器庭用 { get; } = new EchonetObjectSpecification(0x02, 0x67); + public static EchonetObjectSpecification 散水器庭用 { get; } = new(0x02, 0x67); /// /// 0x6B 電気温水器 /// - public static IEchonetObject 電気温水器 { get; } = new EchonetObjectSpecification(0x02, 0x6B); + public static EchonetObjectSpecification 電気温水器 { get; } = new(0x02, 0x6B); /// /// 0x6E 電気便座(温水洗浄便座、暖房便座など) /// - public static IEchonetObject 電気便座温水洗浄便座暖房便座など { get; } = new EchonetObjectSpecification(0x02, 0x6E); + public static EchonetObjectSpecification 電気便座温水洗浄便座暖房便座など { get; } = new(0x02, 0x6E); /// /// 0x6F 電気錠 /// - public static IEchonetObject 電気錠 { get; } = new EchonetObjectSpecification(0x02, 0x6F); + public static EchonetObjectSpecification 電気錠 { get; } = new(0x02, 0x6F); /// /// 0x72 瞬間式給湯器 /// - public static IEchonetObject 瞬間式給湯器 { get; } = new EchonetObjectSpecification(0x02, 0x72); + public static EchonetObjectSpecification 瞬間式給湯器 { get; } = new(0x02, 0x72); /// /// 0x73 浴室暖房乾燥機 /// - public static IEchonetObject 浴室暖房乾燥機 { get; } = new EchonetObjectSpecification(0x02, 0x73); + public static EchonetObjectSpecification 浴室暖房乾燥機 { get; } = new(0x02, 0x73); /// /// 0x79 住宅用太陽光発電 /// - public static IEchonetObject 住宅用太陽光発電 { get; } = new EchonetObjectSpecification(0x02, 0x79); + public static EchonetObjectSpecification 住宅用太陽光発電 { get; } = new(0x02, 0x79); /// /// 0x7A 冷温水熱源機 /// - public static IEchonetObject 冷温水熱源機 { get; } = new EchonetObjectSpecification(0x02, 0x7A); + public static EchonetObjectSpecification 冷温水熱源機 { get; } = new(0x02, 0x7A); /// /// 0x7B 床暖房 /// - public static IEchonetObject 床暖房 { get; } = new EchonetObjectSpecification(0x02, 0x7B); + public static EchonetObjectSpecification 床暖房 { get; } = new(0x02, 0x7B); /// /// 0x7C 燃料電池 /// - public static IEchonetObject 燃料電池 { get; } = new EchonetObjectSpecification(0x02, 0x7C); + public static EchonetObjectSpecification 燃料電池 { get; } = new(0x02, 0x7C); /// /// 0x7D 蓄電池 /// - public static IEchonetObject 蓄電池 { get; } = new EchonetObjectSpecification(0x02, 0x7D); + public static EchonetObjectSpecification 蓄電池 { get; } = new(0x02, 0x7D); /// /// 0x7E 電気自動車充放電器 /// - public static IEchonetObject 電気自動車充放電器 { get; } = new EchonetObjectSpecification(0x02, 0x7E); + public static EchonetObjectSpecification 電気自動車充放電器 { get; } = new(0x02, 0x7E); /// /// 0x7F エンジンコージェネレーション /// - public static IEchonetObject エンジンコージェネレーション { get; } = new EchonetObjectSpecification(0x02, 0x7F); + public static EchonetObjectSpecification エンジンコージェネレーション { get; } = new(0x02, 0x7F); /// /// 0x80 電力量メータ /// - public static IEchonetObject 電力量メータ { get; } = new EchonetObjectSpecification(0x02, 0x80); + public static EchonetObjectSpecification 電力量メータ { get; } = new(0x02, 0x80); /// /// 0x81 水流量メータ /// - public static IEchonetObject 水流量メータ { get; } = new EchonetObjectSpecification(0x02, 0x81); + public static EchonetObjectSpecification 水流量メータ { get; } = new(0x02, 0x81); /// /// 0x82 ガスメータ /// - public static IEchonetObject ガスメータ { get; } = new EchonetObjectSpecification(0x02, 0x82); + public static EchonetObjectSpecification ガスメータ { get; } = new(0x02, 0x82); /// /// 0x83 LP ガスメータ /// - public static IEchonetObject LPガスメータ { get; } = new EchonetObjectSpecification(0x02, 0x83); + public static EchonetObjectSpecification LPガスメータ { get; } = new(0x02, 0x83); /// /// 0x87 分電盤メータリング /// - public static IEchonetObject 分電盤メータリング { get; } = new EchonetObjectSpecification(0x02, 0x87); + public static EchonetObjectSpecification 分電盤メータリング { get; } = new(0x02, 0x87); /// /// 0x88 低圧スマート電力量メータ /// - public static IEchonetObject 低圧スマート電力量メータ { get; } = new EchonetObjectSpecification(0x02, 0x88); + public static EchonetObjectSpecification 低圧スマート電力量メータ { get; } = new(0x02, 0x88); /// /// 0x89 スマートガスメータ /// - public static IEchonetObject スマートガスメータ { get; } = new EchonetObjectSpecification(0x02, 0x89); + public static EchonetObjectSpecification スマートガスメータ { get; } = new(0x02, 0x89); /// /// 0x8A 高圧スマート電力量メータ /// - public static IEchonetObject 高圧スマート電力量メータ { get; } = new EchonetObjectSpecification(0x02, 0x8A); + public static EchonetObjectSpecification 高圧スマート電力量メータ { get; } = new(0x02, 0x8A); /// /// 0x8B 灯油メータ /// - public static IEchonetObject 灯油メータ { get; } = new EchonetObjectSpecification(0x02, 0x8B); + public static EchonetObjectSpecification 灯油メータ { get; } = new(0x02, 0x8B); /// /// 0x8C スマート灯油メータ /// - public static IEchonetObject スマート灯油メータ { get; } = new EchonetObjectSpecification(0x02, 0x8C); + public static EchonetObjectSpecification スマート灯油メータ { get; } = new(0x02, 0x8C); /// /// 0x90 一般照明 /// - public static IEchonetObject 一般照明 { get; } = new EchonetObjectSpecification(0x02, 0x90); + public static EchonetObjectSpecification 一般照明 { get; } = new(0x02, 0x90); /// /// 0x91 単機能照明 /// - public static IEchonetObject 単機能照明 { get; } = new EchonetObjectSpecification(0x02, 0x91); + public static EchonetObjectSpecification 単機能照明 { get; } = new(0x02, 0x91); /// /// 0x92 固体発光光源用照明 /// - public static IEchonetObject 固体発光光源用照明 { get; } = new EchonetObjectSpecification(0x02, 0x92); + public static EchonetObjectSpecification 固体発光光源用照明 { get; } = new(0x02, 0x92); /// /// 0xA0 ブザー /// - public static IEchonetObject ブザー { get; } = new EchonetObjectSpecification(0x02, 0xA0); + public static EchonetObjectSpecification ブザー { get; } = new(0x02, 0xA0); /// /// 0xA1 電気自動車充電器 /// - public static IEchonetObject 電気自動車充電器 { get; } = new EchonetObjectSpecification(0x02, 0xA1); + public static EchonetObjectSpecification 電気自動車充電器 { get; } = new(0x02, 0xA1); /// /// 0xA3 照明システム /// - public static IEchonetObject 照明システム { get; } = new EchonetObjectSpecification(0x02, 0xA3); + public static EchonetObjectSpecification 照明システム { get; } = new(0x02, 0xA3); /// /// 0xA4 拡張照明システム /// - public static IEchonetObject 拡張照明システム { get; } = new EchonetObjectSpecification(0x02, 0xA4); + public static EchonetObjectSpecification 拡張照明システム { get; } = new(0x02, 0xA4); /// /// 0xA5 マルチ入力 PCS /// - public static IEchonetObject マルチ入力PCS { get; } = new EchonetObjectSpecification(0x02, 0xA5); + public static EchonetObjectSpecification マルチ入力PCS { get; } = new(0x02, 0xA5); } /// /// ECHONET Lite クラスグループ定義 @@ -645,43 +600,43 @@ public static class 調理家事関連機器 /// /// 0xB2 電気ポット /// - public static IEchonetObject 電気ポット { get; } = new EchonetObjectSpecification(0x03, 0xB2); + public static EchonetObjectSpecification 電気ポット { get; } = new(0x03, 0xB2); /// /// 0xB7 冷凍冷蔵庫 /// - public static IEchonetObject 冷凍冷蔵庫 { get; } = new EchonetObjectSpecification(0x03, 0xB7); + public static EchonetObjectSpecification 冷凍冷蔵庫 { get; } = new(0x03, 0xB7); /// /// 0xB8 オーブンレンジ /// - public static IEchonetObject オーブンレンジ { get; } = new EchonetObjectSpecification(0x03, 0xB8); + public static EchonetObjectSpecification オーブンレンジ { get; } = new(0x03, 0xB8); /// /// 0xB9 クッキングヒータ /// - public static IEchonetObject クッキングヒータ { get; } = new EchonetObjectSpecification(0x03, 0xB9); + public static EchonetObjectSpecification クッキングヒータ { get; } = new(0x03, 0xB9); /// /// 0xBB 炊飯器 /// - public static IEchonetObject 炊飯器 { get; } = new EchonetObjectSpecification(0x03, 0xBB); + public static EchonetObjectSpecification 炊飯器 { get; } = new(0x03, 0xBB); /// /// 0xC5 洗濯機 /// - public static IEchonetObject 洗濯機 { get; } = new EchonetObjectSpecification(0x03, 0xC5); + public static EchonetObjectSpecification 洗濯機 { get; } = new(0x03, 0xC5); /// /// 0xC6 衣類乾燥機 /// - public static IEchonetObject 衣類乾燥機 { get; } = new EchonetObjectSpecification(0x03, 0xC6); + public static EchonetObjectSpecification 衣類乾燥機 { get; } = new(0x03, 0xC6); /// /// 0xCE 業務用ショーケース /// - public static IEchonetObject 業務用ショーケース { get; } = new EchonetObjectSpecification(0x03, 0xCE); + public static EchonetObjectSpecification 業務用ショーケース { get; } = new(0x03, 0xCE); /// /// 0xD3 洗濯乾燥機 /// - public static IEchonetObject 洗濯乾燥機 { get; } = new EchonetObjectSpecification(0x03, 0xD3); + public static EchonetObjectSpecification 洗濯乾燥機 { get; } = new(0x03, 0xD3); /// /// 0xD4 業務用ショーケース向け室外機 /// - public static IEchonetObject 業務用ショーケース向け室外機 { get; } = new EchonetObjectSpecification(0x03, 0xD4); + public static EchonetObjectSpecification 業務用ショーケース向け室外機 { get; } = new(0x03, 0xD4); } /// @@ -693,7 +648,7 @@ public static class 健康関連機器 /// /// 0x01 体重計 /// - public static IEchonetObject 体重計 { get; } = new EchonetObjectSpecification(0x04, 0x01); + public static EchonetObjectSpecification 体重計 { get; } = new(0x04, 0x01); } /// /// ECHONET Lite クラスグループ定義 @@ -704,23 +659,23 @@ public static class 管理操作関連機器 /// /// 0xFA 並列処理併用型電力制御 /// - public static IEchonetObject 並列処理併用型電力制御 { get; } = new EchonetObjectSpecification(0x05, 0xFA); + public static EchonetObjectSpecification 並列処理併用型電力制御 { get; } = new(0x05, 0xFA); /// /// 0xFB DR イベントコントローラ /// - public static IEchonetObject DRイベントコントローラ { get; } = new EchonetObjectSpecification(0x05, 0xFB); + public static EchonetObjectSpecification DRイベントコントローラ { get; } = new(0x05, 0xFB); /// /// 0xFC セ キ ュ ア 通 信 用 共 有 鍵 設 定 ノード /// - public static IEchonetObject セキュア通信用共有鍵設定ノード { get; } = new EchonetObjectSpecification(0x05, 0xFC); + public static EchonetObjectSpecification セキュア通信用共有鍵設定ノード { get; } = new(0x05, 0xFC); /// /// 0xFD スイッチ(JEMA/HA 端子対応) /// - public static IEchonetObject スイッチJEMAHA端子対応 { get; } = new EchonetObjectSpecification(0x05, 0xFD); + public static EchonetObjectSpecification スイッチJEMAHA端子対応 { get; } = new(0x05, 0xFD); /// /// 0xFF コントローラ /// - public static IEchonetObject コントローラ { get; } = new EchonetObjectSpecification(0x05, 0xFF); + public static EchonetObjectSpecification コントローラ { get; } = new(0x05, 0xFF); } /// /// ECHONET Lite クラスグループ定義 @@ -731,19 +686,19 @@ public static class AV関連機器 /// /// 0x01 ディスプレー /// - public static IEchonetObject ディスプレー { get; } = new EchonetObjectSpecification(0x06, 0x01); + public static EchonetObjectSpecification ディスプレー { get; } = new(0x06, 0x01); /// /// 0x02 テレビ /// - public static IEchonetObject テレビ { get; } = new EchonetObjectSpecification(0x06, 0x02); + public static EchonetObjectSpecification テレビ { get; } = new(0x06, 0x02); /// /// 0x03 オーディオ /// - public static IEchonetObject オーディオ { get; } = new EchonetObjectSpecification(0x06, 0x03); + public static EchonetObjectSpecification オーディオ { get; } = new(0x06, 0x03); /// /// 0x04 ネットワークカメラ /// - public static IEchonetObject ネットワークカメラ { get; } = new EchonetObjectSpecification(0x06, 0x04); + public static EchonetObjectSpecification ネットワークカメラ { get; } = new(0x06, 0x04); } } } diff --git a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/IEchonetObject.cs b/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/IEchonetObject.cs deleted file mode 100644 index a835c1e..0000000 --- a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/IEchonetObject.cs +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-FileCopyrightText: 2018 HiroyukiSakoh -// SPDX-FileCopyrightText: 2023 smdn -// SPDX-License-Identifier: MIT -using System.Collections.Generic; - -using Smdn.Net.EchonetLite.Appendix; - -namespace Smdn.Net.EchonetLite -{ - /// - /// ECHONET Lite オブジェクト - /// - public interface IEchonetObject - { - /// - /// クラスグループ情報 - /// クラスグループコード - /// - EchonetClassGroupSpecification ClassGroup { get; } - /// - /// クラス情報 - /// クラスコード - /// - EchonetClassSpecification Class { get; } - /// - /// 仕様上定義済みのGETプロパティの一覧 - /// - IEnumerable GetProperties { get; } - /// - /// 仕様上定義済みのSETプロパティの一覧 - /// - IEnumerable SetProperties { get; } - /// - /// 仕様上定義済みのANNOプロパティの一覧 - /// - IEnumerable AnnoProperties { get; } - } -} diff --git a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs b/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs index 952f495..6dfb7fb 100644 --- a/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs +++ b/src/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs @@ -16,14 +16,14 @@ public static class Profiles /// /// 0xF0 ノードプロファイル /// - public static IEchonetObject NodeProfile { get; } = new EchonetObjectSpecification(0x0E, 0xF0); + public static EchonetObjectSpecification NodeProfile { get; } = new(0x0E, 0xF0); /// /// クラス一覧 /// - public static IReadOnlyList All { get; } = new IEchonetObject[] - { + public static IReadOnlyList All { get; } = + [ NodeProfile, - }; + ]; } } diff --git a/src/Smdn.Net.EchonetLite/Smdn.Net.EchonetLite/EchonetObject.cs b/src/Smdn.Net.EchonetLite/Smdn.Net.EchonetLite/EchonetObject.cs index 6639a44..e8ec08b 100644 --- a/src/Smdn.Net.EchonetLite/Smdn.Net.EchonetLite/EchonetObject.cs +++ b/src/Smdn.Net.EchonetLite/Smdn.Net.EchonetLite/EchonetObject.cs @@ -7,6 +7,7 @@ using System.Collections.ObjectModel; using System.Linq; +using Smdn.Net.EchonetLite.Appendix; using Smdn.Net.EchonetLite.Protocol; namespace Smdn.Net.EchonetLite @@ -35,7 +36,7 @@ public EchonetObject(EOJ eoj) /// /// オブジェクトクラス /// - public EchonetObject(IEchonetObject classObject,byte instanceCode) + public EchonetObject(EchonetObjectSpecification classObject,byte instanceCode) { Spec = classObject ?? throw new ArgumentNullException(nameof(classObject)); InstanceCode = instanceCode; @@ -107,7 +108,7 @@ internal void ResetProperties(IEnumerable props) /// クラスグループコード、クラスグループ名 /// ECHONET機器オブジェクト詳細規定がある場合、詳細仕様 /// - public IEchonetObject Spec { get; } + public EchonetObjectSpecification Spec { get; } /// /// インスタンスコード /// diff --git a/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs b/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs index c8137b6..1e20cbe 100644 --- a/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs +++ b/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/DeviceClasses.cs @@ -17,20 +17,20 @@ public void ClassGroup() var obj = DeviceClasses.管理操作関連機器.コントローラ; Assert.That(obj, Is.Not.Null); - Assert.That(obj.ClassGroup, Is.Not.Null, nameof(IEchonetObject.ClassGroup)); + Assert.That(obj.ClassGroup, Is.Not.Null, nameof(EchonetObjectSpecification.ClassGroup)); Assert.That(obj.ClassGroup.Code, Is.EqualTo(0x05), nameof(EchonetClassGroupSpecification.Code)); Assert.That(obj.ClassGroup.Name, Is.EqualTo("管理・操作関連機器クラスグループ"), nameof(EchonetClassGroupSpecification.Name)); Assert.That(obj.ClassGroup.SuperClassName, Is.EqualTo("機器オブジェクトスーパークラス"), nameof(EchonetClassGroupSpecification.SuperClassName)); Assert.That(obj.ClassGroup.Classes, Is.Not.Empty, nameof(EchonetClassGroupSpecification.Classes)); - Assert.That(obj.GetProperties, Is.Not.Null, nameof(IEchonetObject.GetProperties)); - Assert.That(obj.GetProperties, Is.Not.Empty, nameof(IEchonetObject.GetProperties)); + Assert.That(obj.GetProperties, Is.Not.Null, nameof(EchonetObjectSpecification.GetProperties)); + Assert.That(obj.GetProperties, Is.Not.Empty, nameof(EchonetObjectSpecification.GetProperties)); - Assert.That(obj.SetProperties, Is.Not.Null, nameof(IEchonetObject.SetProperties)); - Assert.That(obj.SetProperties, Is.Not.Empty, nameof(IEchonetObject.SetProperties)); + Assert.That(obj.SetProperties, Is.Not.Null, nameof(EchonetObjectSpecification.SetProperties)); + Assert.That(obj.SetProperties, Is.Not.Empty, nameof(EchonetObjectSpecification.SetProperties)); - Assert.That(obj.AnnoProperties, Is.Not.Null, nameof(IEchonetObject.AnnoProperties)); - Assert.That(obj.AnnoProperties, Is.Not.Empty, nameof(IEchonetObject.AnnoProperties)); + Assert.That(obj.AnnoProperties, Is.Not.Null, nameof(EchonetObjectSpecification.AnnoProperties)); + Assert.That(obj.AnnoProperties, Is.Not.Empty, nameof(EchonetObjectSpecification.AnnoProperties)); } [Test] @@ -39,18 +39,18 @@ public void Class() var obj = DeviceClasses.管理操作関連機器.コントローラ; Assert.That(obj, Is.Not.Null); - Assert.That(obj.Class, Is.Not.Null, nameof(IEchonetObject.Class)); + Assert.That(obj.Class, Is.Not.Null, nameof(EchonetObjectSpecification.Class)); Assert.That(obj.Class.Code, Is.EqualTo(0xFF), nameof(EchonetClassSpecification.Code)); Assert.That(obj.Class.Name, Is.EqualTo("コントローラ"), nameof(EchonetClassSpecification.Name)); - Assert.That(obj.GetProperties, Is.Not.Null, nameof(IEchonetObject.GetProperties)); - Assert.That(obj.GetProperties, Is.Not.Empty, nameof(IEchonetObject.GetProperties)); + Assert.That(obj.GetProperties, Is.Not.Null, nameof(EchonetObjectSpecification.GetProperties)); + Assert.That(obj.GetProperties, Is.Not.Empty, nameof(EchonetObjectSpecification.GetProperties)); - Assert.That(obj.SetProperties, Is.Not.Null, nameof(IEchonetObject.SetProperties)); - Assert.That(obj.SetProperties, Is.Not.Empty, nameof(IEchonetObject.SetProperties)); + Assert.That(obj.SetProperties, Is.Not.Null, nameof(EchonetObjectSpecification.SetProperties)); + Assert.That(obj.SetProperties, Is.Not.Empty, nameof(EchonetObjectSpecification.SetProperties)); - Assert.That(obj.AnnoProperties, Is.Not.Null, nameof(IEchonetObject.AnnoProperties)); - Assert.That(obj.AnnoProperties, Is.Not.Empty, nameof(IEchonetObject.AnnoProperties)); + Assert.That(obj.AnnoProperties, Is.Not.Null, nameof(EchonetObjectSpecification.AnnoProperties)); + Assert.That(obj.AnnoProperties, Is.Not.Empty, nameof(EchonetObjectSpecification.AnnoProperties)); } private static System.Collections.IEnumerable YieldTestCases_機器オブジェクトスーパークラスJson() @@ -61,7 +61,7 @@ private static System.Collections.IEnumerable YieldTestCases_機器オブジェ } [TestCaseSource(nameof(YieldTestCases_機器オブジェクトスーパークラスJson))] - public void 機器オブジェクトスーパークラスJson(IEchonetObject obj) + public void 機器オブジェクトスーパークラスJson(EchonetObjectSpecification obj) { var epc80 = obj.GetProperties.FirstOrDefault(static prop => prop.Name == "動作状態"); diff --git a/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs b/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs index 7507a7f..c14c262 100644 --- a/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs +++ b/tests/Smdn.Net.EchonetLite.Appendix/Smdn.Net.EchonetLite/Profiles.cs @@ -16,7 +16,7 @@ public void ノードプロファイル() var p = Profiles.NodeProfile; Assert.That(p, Is.Not.Null); - Assert.That(p.ClassGroup, Is.Not.Null, nameof(IEchonetObject.ClassGroup)); + Assert.That(p.ClassGroup, Is.Not.Null, nameof(EchonetObjectSpecification.ClassGroup)); Assert.That(p.ClassGroup.Code, Is.EqualTo(0x0E), nameof(EchonetClassGroupSpecification.Code)); Assert.That(p.ClassGroup.Name, Is.EqualTo("プロファイルクラスグループ"), nameof(EchonetClassGroupSpecification.Name)); Assert.That(p.ClassGroup.SuperClassName, Is.EqualTo("プロファイルオブジェクトスーパークラス"), nameof(EchonetClassGroupSpecification.SuperClassName));