OpenECHO
 All Classes Namespaces Files Functions Variables
ElectricHotWaterPot.java
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Sony Computer Science Laboratories, Inc. <info@kadecot.net>
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.sonycsl.echo.eoj.device.cookinghousehold;
17 
25 
26 public abstract class ElectricHotWaterPot extends DeviceObject {
27 
28  public static final short ECHO_CLASS_CODE = (short)0x03B2;
29 
30  public static final byte EPC_COVER_OPEN_CLOSE_STATUS = (byte)0xB0;
31  public static final byte EPC_NO_WATER_WARNING = (byte)0xB1;
32  public static final byte EPC_BOIL_UP_SETTING = (byte)0xB2;
33  public static final byte EPC_BOIL_UP_WARMER_MODE_SETTING = (byte)0xE0;
34  public static final byte EPC_SET_VALUE_OF_WARMER_TEMPERATURE = (byte)0xE1;
35  public static final byte EPC_HOT_WATER_DISCHARGE_STATUS = (byte)0xE2;
36  public static final byte EPC_LOCK_STATUS = (byte)0xE3;
37 
38  @Override
39  protected void setupPropertyMaps() {
40  super.setupPropertyMaps();
41 
47  }
48 
49  @Override
50  public void onNew() {
51  super.onNew();
52  Echo.getEventListener().onNewElectricHotWaterPot(this);
53  }
54 
55  @Override
56  public short getEchoClassCode() {
57  return ECHO_CLASS_CODE;
58  }
59 
84  protected boolean setOperationStatus(byte[] edt) {return false;}
109  protected abstract byte[] getOperationStatus();
132  protected byte[] getCoverOpenCloseStatus() {return null;}
155  protected boolean isValidCoverOpenCloseStatus(byte[] edt) {
156  if(edt == null || !(edt.length == 1)) return false;
157  return true;
158  }
184  protected byte[] getNoWaterWarning() {return null;}
210  protected boolean isValidNoWaterWarning(byte[] edt) {
211  if(edt == null || !(edt.length == 1)) return false;
212  return true;
213  }
237  protected boolean setBoilUpSetting(byte[] edt) {return false;}
261  protected byte[] getBoilUpSetting() {return null;}
285  protected boolean isValidBoilUpSetting(byte[] edt) {
286  if(edt == null || !(edt.length == 1)) return false;
287  return true;
288  }
312  protected boolean setBoilUpWarmerModeSetting(byte[] edt) {return false;}
336  protected byte[] getBoilUpWarmerModeSetting() {return null;}
360  protected boolean isValidBoilUpWarmerModeSetting(byte[] edt) {
361  if(edt == null || !(edt.length == 1)) return false;
362  return true;
363  }
386  protected boolean setSetValueOfWarmerTemperature(byte[] edt) {return false;}
409  protected byte[] getSetValueOfWarmerTemperature() {return null;}
432  protected boolean isValidSetValueOfWarmerTemperature(byte[] edt) {
433  if(edt == null || !(edt.length == 1)) return false;
434  return true;
435  }
460  protected byte[] getHotWaterDischargeStatus() {return null;}
485  protected boolean isValidHotWaterDischargeStatus(byte[] edt) {
486  if(edt == null || !(edt.length == 1)) return false;
487  return true;
488  }
511  protected byte[] getLockStatus() {return null;}
534  protected boolean isValidLockStatus(byte[] edt) {
535  if(edt == null || !(edt.length == 1)) return false;
536  return true;
537  }
538 
539  @Override
540  protected synchronized boolean setProperty(EchoProperty property) {
541  boolean success = super.setProperty(property);
542  if(success) return success;
543 
544  switch(property.epc) {
545  case EPC_BOIL_UP_SETTING : return setBoilUpSetting(property.edt);
548  default : return false;
549  }
550  }
551 
552  @Override
553  protected synchronized byte[] getProperty(byte epc) {
554  byte[] edt = super.getProperty(epc);
555  if(edt != null) return edt;
556 
557  switch(epc) {
559  case EPC_NO_WATER_WARNING : return getNoWaterWarning();
560  case EPC_BOIL_UP_SETTING : return getBoilUpSetting();
564  case EPC_LOCK_STATUS : return getLockStatus();
565  default : return null;
566  }
567  }
568 
569  @Override
570  protected synchronized boolean isValidProperty(EchoProperty property) {
571  boolean valid = super.isValidProperty(property);
572  if(valid) return valid;
573 
574  switch(property.epc) {
576  case EPC_NO_WATER_WARNING : return isValidNoWaterWarning(property.edt);
577  case EPC_BOIL_UP_SETTING : return isValidBoilUpSetting(property.edt);
581  case EPC_LOCK_STATUS : return isValidLockStatus(property.edt);
582  default : return false;
583  }
584  }
585 
586  @Override
587  public Setter set() {
588  return set(true);
589  }
590 
591  @Override
592  public Setter set(boolean responseRequired) {
593  return new Setter(getEchoClassCode(), getInstanceCode()
594  , getNode().getAddressStr(), responseRequired);
595  }
596 
597  @Override
598  public Getter get() {
599  return new Getter(getEchoClassCode(), getInstanceCode()
600  , getNode().getAddressStr());
601  }
602 
603  @Override
604  public Informer inform() {
605  return inform(isSelfObject());
606  }
607 
608  @Override
609  protected Informer inform(boolean multicast) {
610  String address;
611  if(multicast) {
613  } else {
614  address = getNode().getAddressStr();
615  }
616  return new Informer(getEchoClassCode(), getInstanceCode()
617  , address, isSelfObject());
618  }
619 
620  public static class Receiver extends DeviceObject.Receiver {
621 
622  @Override
623  protected boolean onSetProperty(EchoObject eoj, short tid, byte esv,
624  EchoProperty property, boolean success) {
625  boolean ret = super.onSetProperty(eoj, tid, esv, property, success);
626  if(ret) return true;
627 
628  switch(property.epc) {
629  case EPC_BOIL_UP_SETTING :
630  onSetBoilUpSetting(eoj, tid, esv, property, success);
631  return true;
633  onSetBoilUpWarmerModeSetting(eoj, tid, esv, property, success);
634  return true;
636  onSetSetValueOfWarmerTemperature(eoj, tid, esv, property, success);
637  return true;
638  default :
639  return false;
640  }
641  }
642 
643  @Override
644  protected boolean onGetProperty(EchoObject eoj, short tid, byte esv,
645  EchoProperty property, boolean success) {
646  boolean ret = super.onGetProperty(eoj, tid, esv, property, success);
647  if(ret) return true;
648 
649  switch(property.epc) {
651  onGetCoverOpenCloseStatus(eoj, tid, esv, property, success);
652  return true;
653  case EPC_NO_WATER_WARNING :
654  onGetNoWaterWarning(eoj, tid, esv, property, success);
655  return true;
656  case EPC_BOIL_UP_SETTING :
657  onGetBoilUpSetting(eoj, tid, esv, property, success);
658  return true;
660  onGetBoilUpWarmerModeSetting(eoj, tid, esv, property, success);
661  return true;
663  onGetSetValueOfWarmerTemperature(eoj, tid, esv, property, success);
664  return true;
666  onGetHotWaterDischargeStatus(eoj, tid, esv, property, success);
667  return true;
668  case EPC_LOCK_STATUS :
669  onGetLockStatus(eoj, tid, esv, property, success);
670  return true;
671  default :
672  return false;
673  }
674  }
675 
698  protected void onGetCoverOpenCloseStatus(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
724  protected void onGetNoWaterWarning(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
748  protected void onSetBoilUpSetting(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
772  protected void onGetBoilUpSetting(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
796  protected void onSetBoilUpWarmerModeSetting(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
820  protected void onGetBoilUpWarmerModeSetting(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
843  protected void onSetSetValueOfWarmerTemperature(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
866  protected void onGetSetValueOfWarmerTemperature(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
891  protected void onGetHotWaterDischargeStatus(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
914  protected void onGetLockStatus(EchoObject eoj, short tid, byte esv, EchoProperty property, boolean success) {}
915  }
916 
917  public static class Setter extends DeviceObject.Setter {
918  public Setter(short dstEchoClassCode, byte dstEchoInstanceCode
919  , String dstEchoAddress, boolean responseRequired) {
920  super(dstEchoClassCode, dstEchoInstanceCode
921  , dstEchoAddress, responseRequired);
922  }
923 
924  @Override
925  public Setter reqSetProperty(byte epc, byte[] edt) {
926  return (Setter)super.reqSetProperty(epc, edt);
927  }
928 
929  @Override
930  public Setter reqSetOperationStatus(byte[] edt) {
931  return (Setter)super.reqSetOperationStatus(edt);
932  }
933  @Override
934  public Setter reqSetInstallationLocation(byte[] edt) {
935  return (Setter)super.reqSetInstallationLocation(edt);
936  }
937  @Override
938  public Setter reqSetCurrentLimitSetting(byte[] edt) {
939  return (Setter)super.reqSetCurrentLimitSetting(edt);
940  }
941  @Override
942  public Setter reqSetPowerSavingOperationSetting(byte[] edt) {
943  return (Setter)super.reqSetPowerSavingOperationSetting(edt);
944  }
945  @Override
946  public Setter reqSetRemoteControlSetting(byte[] edt) {
947  return (Setter)super.reqSetRemoteControlSetting(edt);
948  }
949  @Override
950  public Setter reqSetCurrentTimeSetting(byte[] edt) {
951  return (Setter)super.reqSetCurrentTimeSetting(edt);
952  }
953  @Override
954  public Setter reqSetCurrentDateSetting(byte[] edt) {
955  return (Setter)super.reqSetCurrentDateSetting(edt);
956  }
957  @Override
958  public Setter reqSetPowerLimitSetting(byte[] edt) {
959  return (Setter)super.reqSetPowerLimitSetting(edt);
960  }
961 
985  public Setter reqSetBoilUpSetting(byte[] edt) {
986  reqSetProperty(EPC_BOIL_UP_SETTING, edt);
987  return this;
988  }
1012  public Setter reqSetBoilUpWarmerModeSetting(byte[] edt) {
1013  reqSetProperty(EPC_BOIL_UP_WARMER_MODE_SETTING, edt);
1014  return this;
1015  }
1038  public Setter reqSetSetValueOfWarmerTemperature(byte[] edt) {
1039  reqSetProperty(EPC_SET_VALUE_OF_WARMER_TEMPERATURE, edt);
1040  return this;
1041  }
1042  }
1043 
1044  public static class Getter extends DeviceObject.Getter {
1045  public Getter(short dstEchoClassCode, byte dstEchoInstanceCode
1046  , String dstEchoAddress) {
1047  super(dstEchoClassCode, dstEchoInstanceCode
1048  , dstEchoAddress);
1049  }
1050 
1051  @Override
1052  public Getter reqGetProperty(byte epc) {
1053  return (Getter)super.reqGetProperty(epc);
1054  }
1055 
1056  @Override
1057  public Getter reqGetOperationStatus() {
1058  return (Getter)super.reqGetOperationStatus();
1059  }
1060  @Override
1061  public Getter reqGetInstallationLocation() {
1062  return (Getter)super.reqGetInstallationLocation();
1063  }
1064  @Override
1065  public Getter reqGetStandardVersionInformation() {
1066  return (Getter)super.reqGetStandardVersionInformation();
1067  }
1068  @Override
1069  public Getter reqGetIdentificationNumber() {
1070  return (Getter)super.reqGetIdentificationNumber();
1071  }
1072  @Override
1073  public Getter reqGetMeasuredInstantaneousPowerConsumption() {
1074  return (Getter)super.reqGetMeasuredInstantaneousPowerConsumption();
1075  }
1076  @Override
1077  public Getter reqGetMeasuredCumulativePowerConsumption() {
1078  return (Getter)super.reqGetMeasuredCumulativePowerConsumption();
1079  }
1080  @Override
1081  public Getter reqGetManufacturersFaultCode() {
1082  return (Getter)super.reqGetManufacturersFaultCode();
1083  }
1084  @Override
1085  public Getter reqGetCurrentLimitSetting() {
1086  return (Getter)super.reqGetCurrentLimitSetting();
1087  }
1088  @Override
1089  public Getter reqGetFaultStatus() {
1090  return (Getter)super.reqGetFaultStatus();
1091  }
1092  @Override
1093  public Getter reqGetFaultDescription() {
1094  return (Getter)super.reqGetFaultDescription();
1095  }
1096  @Override
1097  public Getter reqGetManufacturerCode() {
1098  return (Getter)super.reqGetManufacturerCode();
1099  }
1100  @Override
1101  public Getter reqGetBusinessFacilityCode() {
1102  return (Getter)super.reqGetBusinessFacilityCode();
1103  }
1104  @Override
1105  public Getter reqGetProductCode() {
1106  return (Getter)super.reqGetProductCode();
1107  }
1108  @Override
1109  public Getter reqGetProductionNumber() {
1110  return (Getter)super.reqGetProductionNumber();
1111  }
1112  @Override
1113  public Getter reqGetProductionDate() {
1114  return (Getter)super.reqGetProductionDate();
1115  }
1116  @Override
1117  public Getter reqGetPowerSavingOperationSetting() {
1118  return (Getter)super.reqGetPowerSavingOperationSetting();
1119  }
1120  @Override
1121  public Getter reqGetRemoteControlSetting() {
1122  return (Getter)super.reqGetRemoteControlSetting();
1123  }
1124  @Override
1125  public Getter reqGetCurrentTimeSetting() {
1126  return (Getter)super.reqGetCurrentTimeSetting();
1127  }
1128  @Override
1129  public Getter reqGetCurrentDateSetting() {
1130  return (Getter)super.reqGetCurrentDateSetting();
1131  }
1132  @Override
1133  public Getter reqGetPowerLimitSetting() {
1134  return (Getter)super.reqGetPowerLimitSetting();
1135  }
1136  @Override
1137  public Getter reqGetCumulativeOperatingTime() {
1138  return (Getter)super.reqGetCumulativeOperatingTime();
1139  }
1140  @Override
1141  public Getter reqGetStatusChangeAnnouncementPropertyMap() {
1142  return (Getter)super.reqGetStatusChangeAnnouncementPropertyMap();
1143  }
1144  @Override
1145  public Getter reqGetSetPropertyMap() {
1146  return (Getter)super.reqGetSetPropertyMap();
1147  }
1148  @Override
1149  public Getter reqGetGetPropertyMap() {
1150  return (Getter)super.reqGetGetPropertyMap();
1151  }
1152 
1175  public Getter reqGetCoverOpenCloseStatus() {
1176  reqGetProperty(EPC_COVER_OPEN_CLOSE_STATUS);
1177  return this;
1178  }
1204  public Getter reqGetNoWaterWarning() {
1205  reqGetProperty(EPC_NO_WATER_WARNING);
1206  return this;
1207  }
1231  public Getter reqGetBoilUpSetting() {
1232  reqGetProperty(EPC_BOIL_UP_SETTING);
1233  return this;
1234  }
1258  public Getter reqGetBoilUpWarmerModeSetting() {
1259  reqGetProperty(EPC_BOIL_UP_WARMER_MODE_SETTING);
1260  return this;
1261  }
1284  public Getter reqGetSetValueOfWarmerTemperature() {
1285  reqGetProperty(EPC_SET_VALUE_OF_WARMER_TEMPERATURE);
1286  return this;
1287  }
1312  public Getter reqGetHotWaterDischargeStatus() {
1313  reqGetProperty(EPC_HOT_WATER_DISCHARGE_STATUS);
1314  return this;
1315  }
1338  public Getter reqGetLockStatus() {
1339  reqGetProperty(EPC_LOCK_STATUS);
1340  return this;
1341  }
1342  }
1343 
1344  public static class Informer extends DeviceObject.Informer {
1345  public Informer(short echoClassCode, byte echoInstanceCode
1346  , String dstEchoAddress, boolean isSelfObject) {
1347  super(echoClassCode, echoInstanceCode
1348  , dstEchoAddress, isSelfObject);
1349  }
1350 
1351  @Override
1352  public Informer reqInformProperty(byte epc) {
1353  return (Informer)super.reqInformProperty(epc);
1354  }
1355  @Override
1356  public Informer reqInformOperationStatus() {
1357  return (Informer)super.reqInformOperationStatus();
1358  }
1359  @Override
1360  public Informer reqInformInstallationLocation() {
1361  return (Informer)super.reqInformInstallationLocation();
1362  }
1363  @Override
1364  public Informer reqInformStandardVersionInformation() {
1365  return (Informer)super.reqInformStandardVersionInformation();
1366  }
1367  @Override
1368  public Informer reqInformIdentificationNumber() {
1369  return (Informer)super.reqInformIdentificationNumber();
1370  }
1371  @Override
1372  public Informer reqInformMeasuredInstantaneousPowerConsumption() {
1373  return (Informer)super.reqInformMeasuredInstantaneousPowerConsumption();
1374  }
1375  @Override
1376  public Informer reqInformMeasuredCumulativePowerConsumption() {
1377  return (Informer)super.reqInformMeasuredCumulativePowerConsumption();
1378  }
1379  @Override
1380  public Informer reqInformManufacturersFaultCode() {
1381  return (Informer)super.reqInformManufacturersFaultCode();
1382  }
1383  @Override
1384  public Informer reqInformCurrentLimitSetting() {
1385  return (Informer)super.reqInformCurrentLimitSetting();
1386  }
1387  @Override
1388  public Informer reqInformFaultStatus() {
1389  return (Informer)super.reqInformFaultStatus();
1390  }
1391  @Override
1392  public Informer reqInformFaultDescription() {
1393  return (Informer)super.reqInformFaultDescription();
1394  }
1395  @Override
1396  public Informer reqInformManufacturerCode() {
1397  return (Informer)super.reqInformManufacturerCode();
1398  }
1399  @Override
1400  public Informer reqInformBusinessFacilityCode() {
1401  return (Informer)super.reqInformBusinessFacilityCode();
1402  }
1403  @Override
1404  public Informer reqInformProductCode() {
1405  return (Informer)super.reqInformProductCode();
1406  }
1407  @Override
1408  public Informer reqInformProductionNumber() {
1409  return (Informer)super.reqInformProductionNumber();
1410  }
1411  @Override
1412  public Informer reqInformProductionDate() {
1413  return (Informer)super.reqInformProductionDate();
1414  }
1415  @Override
1416  public Informer reqInformPowerSavingOperationSetting() {
1417  return (Informer)super.reqInformPowerSavingOperationSetting();
1418  }
1419  @Override
1420  public Informer reqInformRemoteControlSetting() {
1421  return (Informer)super.reqInformRemoteControlSetting();
1422  }
1423  @Override
1424  public Informer reqInformCurrentTimeSetting() {
1425  return (Informer)super.reqInformCurrentTimeSetting();
1426  }
1427  @Override
1428  public Informer reqInformCurrentDateSetting() {
1429  return (Informer)super.reqInformCurrentDateSetting();
1430  }
1431  @Override
1432  public Informer reqInformPowerLimitSetting() {
1433  return (Informer)super.reqInformPowerLimitSetting();
1434  }
1435  @Override
1436  public Informer reqInformCumulativeOperatingTime() {
1437  return (Informer)super.reqInformCumulativeOperatingTime();
1438  }
1439  @Override
1440  public Informer reqInformStatusChangeAnnouncementPropertyMap() {
1441  return (Informer)super.reqInformStatusChangeAnnouncementPropertyMap();
1442  }
1443  @Override
1444  public Informer reqInformSetPropertyMap() {
1445  return (Informer)super.reqInformSetPropertyMap();
1446  }
1447  @Override
1448  public Informer reqInformGetPropertyMap() {
1449  return (Informer)super.reqInformGetPropertyMap();
1450  }
1451 
1474  public Informer reqInformCoverOpenCloseStatus() {
1475  reqInformProperty(EPC_COVER_OPEN_CLOSE_STATUS);
1476  return this;
1477  }
1503  public Informer reqInformNoWaterWarning() {
1504  reqInformProperty(EPC_NO_WATER_WARNING);
1505  return this;
1506  }
1530  public Informer reqInformBoilUpSetting() {
1531  reqInformProperty(EPC_BOIL_UP_SETTING);
1532  return this;
1533  }
1557  public Informer reqInformBoilUpWarmerModeSetting() {
1558  reqInformProperty(EPC_BOIL_UP_WARMER_MODE_SETTING);
1559  return this;
1560  }
1583  public Informer reqInformSetValueOfWarmerTemperature() {
1584  reqInformProperty(EPC_SET_VALUE_OF_WARMER_TEMPERATURE);
1585  return this;
1586  }
1611  public Informer reqInformHotWaterDischargeStatus() {
1612  reqInformProperty(EPC_HOT_WATER_DISCHARGE_STATUS);
1613  return this;
1614  }
1637  public Informer reqInformLockStatus() {
1638  reqInformProperty(EPC_LOCK_STATUS);
1639  return this;
1640  }
1641  }
1642 
1643  public static class Proxy extends ElectricHotWaterPot {
1644  public Proxy(byte instanceCode) {
1645  super();
1646  mEchoInstanceCode = instanceCode;
1647  }
1648  @Override
1649  public byte getInstanceCode() {
1650  return mEchoInstanceCode;
1651  }
1652  @Override
1653  protected byte[] getOperationStatus() {return null;}
1654  @Override
1655  protected boolean setInstallationLocation(byte[] edt) {return false;}
1656  @Override
1657  protected byte[] getInstallationLocation() {return null;}
1658  @Override
1659  protected byte[] getStandardVersionInformation() {return null;}
1660  @Override
1661  protected byte[] getFaultStatus() {return null;}
1662  @Override
1663  protected byte[] getManufacturerCode() {return null;}
1664  }
1665 
1666  public static Setter setG() {
1667  return setG((byte)0);
1668  }
1669 
1670  public static Setter setG(byte instanceCode) {
1671  return setG(instanceCode, true);
1672  }
1673 
1674  public static Setter setG(boolean responseRequired) {
1675  return setG((byte)0, responseRequired);
1676  }
1677 
1678  public static Setter setG(byte instanceCode, boolean responseRequired) {
1679  return new Setter(ECHO_CLASS_CODE, instanceCode
1680  , EchoSocket.MULTICAST_ADDRESS, responseRequired);
1681  }
1682 
1683  public static Getter getG() {
1684  return getG((byte)0);
1685  }
1686 
1687  public static Getter getG(byte instanceCode) {
1688  return new Getter(ECHO_CLASS_CODE, instanceCode
1690  }
1691 
1692  public static Informer informG() {
1693  return informG((byte)0);
1694  }
1695 
1696  public static Informer informG(byte instanceCode) {
1697  return new Informer(ECHO_CLASS_CODE, instanceCode
1698  , EchoSocket.MULTICAST_ADDRESS, false);
1699  }
1700 
1701 }
final void removeSetProperty(byte epc)
Definition: EchoObject.java:98
final void addStatusChangeAnnouncementProperty(byte epc)
Definition: EchoObject.java:71
final void addGetProperty(byte epc)
static Setter setG(byte instanceCode, boolean responseRequired)
abstract boolean setInstallationLocation(byte[] edt)
static final String MULTICAST_ADDRESS
Definition: EchoSocket.java:53