[270] | 1 | /*
|
---|
[287] | 2 | * TOPPERS/ECNL Prototyping tool
|
---|
[270] | 3 | *
|
---|
[287] | 4 | * Copyright (C) 2015,2017 Cores Co., Ltd. Japan
|
---|
[270] | 5 | *
|
---|
| 6 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 7 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 8 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 9 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 10 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 11 | * スコード中に含まれていること.
|
---|
| 12 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 13 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 14 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 15 | * の無保証規定を掲載すること.
|
---|
| 16 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 17 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 18 | * と.
|
---|
| 19 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 20 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 21 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 22 | * 報告すること.
|
---|
| 23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 25 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 26 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 27 | * 免責すること.
|
---|
| 28 | *
|
---|
| 29 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 30 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 31 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 32 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 33 | * の責任を負わない.
|
---|
| 34 | *
|
---|
| 35 | * @(#) $Id$
|
---|
| 36 | */
|
---|
| 37 | using System;
|
---|
| 38 |
|
---|
| 39 | namespace WebMrbc
|
---|
| 40 | {
|
---|
| 41 | public class JsonClassGroupInfo
|
---|
| 42 | {
|
---|
| 43 | public byte classGroupCode;
|
---|
| 44 | public string description;
|
---|
| 45 | public string define;
|
---|
| 46 | public JsonClassInfo[] classes;
|
---|
| 47 |
|
---|
| 48 | public JsonClassGroupInfo(dynamic p)
|
---|
| 49 | {
|
---|
| 50 | classGroupCode = p.classGroupCode;
|
---|
| 51 | description = p.description;
|
---|
| 52 | define = p.define;
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | public class JsonClassInfo
|
---|
| 57 | {
|
---|
| 58 | public byte classCode;
|
---|
| 59 | public string description;
|
---|
| 60 | public string name;
|
---|
| 61 | public JsonClassGroupInfo classGroup;
|
---|
| 62 | public JsonPropertyInfo[] properties;
|
---|
| 63 |
|
---|
| 64 | public JsonClassInfo(dynamic p)
|
---|
| 65 | {
|
---|
| 66 | classCode = p.classCode;
|
---|
| 67 | description = p.description;
|
---|
| 68 | name = p.name;
|
---|
| 69 | classGroup = p.classGroup;
|
---|
| 70 | properties = p.properties;
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | public class JsonNodeInfo : JsonObjectInfo
|
---|
| 75 | {
|
---|
| 76 | public JsonObjectInfo[] objects;
|
---|
| 77 |
|
---|
| 78 | public JsonNodeInfo(JsonClassInfo type, string identifier, string attribute)
|
---|
| 79 | : base(type, identifier)
|
---|
| 80 | {
|
---|
| 81 | this.attribute = attribute;
|
---|
| 82 | this.objects = new JsonObjectInfo[0];
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | public class JsonObjectInfo
|
---|
| 87 | {
|
---|
| 88 | public JsonClassInfo type;
|
---|
| 89 | public JsonNodeInfo parent;
|
---|
| 90 | public string identifier;
|
---|
| 91 | public byte instanceCode;
|
---|
| 92 | public string attribute;
|
---|
| 93 | public JsonPropertyInfo[] properties;
|
---|
| 94 |
|
---|
| 95 | public JsonObjectInfo(JsonClassInfo type, string identifier)
|
---|
| 96 | {
|
---|
| 97 | this.type = type;
|
---|
| 98 | this.identifier = identifier;
|
---|
| 99 | this.instanceCode = 1;
|
---|
| 100 | this.attribute = "device";
|
---|
| 101 | this.properties = new JsonPropertyInfo[0];
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | public JsonPropertyInfo FindProperty(byte epc)
|
---|
| 105 | {
|
---|
| 106 | foreach (var item in this.properties) {
|
---|
| 107 | if (item.propertyCode == epc)
|
---|
| 108 | return item;
|
---|
| 109 | }
|
---|
| 110 | return null;
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | public static class JsonObjectInfoExtention
|
---|
| 115 | {
|
---|
| 116 | public static JsonObjectInfo Clone(this JsonObjectInfo obj)
|
---|
| 117 | {
|
---|
| 118 | return new JsonObjectInfo(obj.type, obj.identifier) {
|
---|
| 119 | parent = obj.parent,
|
---|
| 120 | instanceCode = obj.instanceCode,
|
---|
| 121 | attribute = obj.attribute,
|
---|
| 122 | properties = (JsonPropertyInfo[])obj.properties.Clone()
|
---|
| 123 | };
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | public static void Copy(this JsonObjectInfo dst, JsonObjectInfo src)
|
---|
| 127 | {
|
---|
| 128 | dst.type = src.type;
|
---|
| 129 | dst.identifier = src.identifier;
|
---|
| 130 | dst.parent = src.parent;
|
---|
| 131 | dst.instanceCode = src.instanceCode;
|
---|
| 132 | dst.attribute = src.attribute;
|
---|
| 133 | dst.properties = (JsonPropertyInfo[])src.properties.Clone();
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | public class JsonFieldInfo
|
---|
| 138 | {
|
---|
| 139 | public string description;
|
---|
| 140 | public string valueDescription;
|
---|
| 141 | public string unitDescription;
|
---|
| 142 | public string initialValue;
|
---|
| 143 | public string type;
|
---|
| 144 | public string identifier;
|
---|
| 145 | public bool primitive;
|
---|
| 146 | public bool isArray;
|
---|
| 147 | public int arrayCount;
|
---|
| 148 | public int size;
|
---|
| 149 | public JsonFieldInfo[] fields;
|
---|
| 150 |
|
---|
| 151 | public JsonFieldInfo()
|
---|
| 152 | {
|
---|
| 153 |
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | public JsonFieldInfo(dynamic f)
|
---|
| 157 | {
|
---|
| 158 | description = f.description;
|
---|
| 159 | valueDescription = f.valueDescription;
|
---|
| 160 | unitDescription = f.unitDescription;
|
---|
| 161 | initialValue = f.initialValue;
|
---|
| 162 | type = f.type;
|
---|
| 163 | identifier = f.identifier;
|
---|
| 164 | primitive = f.primitive;
|
---|
| 165 | isArray = f.isArray;
|
---|
| 166 | arrayCount = (int)f.arrayCount;
|
---|
| 167 | size = (int)f.size;
|
---|
| 168 | var list = new JsonFieldInfo[0];
|
---|
| 169 | foreach (var field in f.fields) {
|
---|
| 170 | list.Push(new JsonFieldInfo(field));
|
---|
| 171 | }
|
---|
| 172 | fields = list;
|
---|
| 173 | }
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | public class JsonPropertyInfo : JsonFieldInfo
|
---|
| 177 | {
|
---|
| 178 | public JsonObjectInfo classInfo;
|
---|
| 179 | public byte propertyCode;
|
---|
| 180 | public string[] access;
|
---|
| 181 | public string[] required;
|
---|
| 182 |
|
---|
| 183 | public JsonPropertyInfo()
|
---|
| 184 | {
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | public JsonPropertyInfo(dynamic p)
|
---|
| 188 | : base((object)p)
|
---|
| 189 | {
|
---|
| 190 | classInfo = p.classInfo;
|
---|
| 191 | propertyCode = p.propertyCode;
|
---|
| 192 | access = p.access;
|
---|
| 193 | required = p.required;
|
---|
| 194 | }
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | public class JsonSkeltonResult
|
---|
| 198 | {
|
---|
| 199 | public string macro;
|
---|
| 200 | public string declare;
|
---|
| 201 | public string predefine;
|
---|
| 202 | public string types;
|
---|
| 203 | public string funcs;
|
---|
| 204 | public string instance;
|
---|
| 205 | public string define;
|
---|
| 206 | public string config;
|
---|
| 207 | }
|
---|
| 208 | }
|
---|