📄 epcgscalar.java
字号:
setValue(new OctetString(((ReaderDevice)(objects[0])).getDescription()));
break;
case EPCG_RDR_DEV_ROLE:
setValue(new OctetString(((ReaderDevice)(objects[0])).getRole()));
break;
case EPCG_RDR_DEV_EPC:
setValue(new OctetString(((ReaderDevice)(objects[0])).getEPC()));
break;
case EPCG_RDR_DEV_SERIAL_NUMBER:
setValue(new OctetString(((ReaderDevice)(objects[0])).getSerialNumber()));
break;
case EPCG_RDR_DEV_TIME_UTC:
setValue(SnmpUtil.dateToOctetString(((ReaderDevice)(objects[0])).getTimeUTC()));
break;
case EPCG_RDR_DEV_CURRENT_SOURCE:
SnmpTable sourceTable = (SnmpTable)SnmpUtil.getSnmpTable(TableTypeEnum.EPCG_SOURCE_TABLE);
String sourceName = ((ReaderDevice)objects[0]).getCurrentSource().getName();
OID index = sourceTable.getTableRowIndexByValue(new OctetString(sourceName), EpcglobalReaderMib.idxEpcgSrcName);
OID oid = new OID(EpcglobalReaderMib.oidEpcgSourceEntry);
oid.append(EpcglobalReaderMib.colEpcgSrcName);
oid.append(index);
setValue(oid);
break;
case EPCG_RDR_DEV_REBOOT:
setValue(new Integer32(2));
break;
case EPCG_RDR_DEV_RESET_STATISTICS:
setValue(new Integer32(2));
break;
case EPCG_RDR_DEV_RESET_TIMESTAMP:
// do nothing
break;
case EPCG_RDR_DEV_NORMALIZE_POWER_LEVEL:
setValue(new Integer32(1));
break;
case EPCG_RDR_DEV_NORMALIZE_NOISE_LEVEL:
setValue(new Integer32(1));
break;
case EPCG_RDR_DEV_OPER_STATUS:
setValue(new Integer32(((ReaderDevice)objects[0]).getOperStatus().toInt()));
break;
case EPCG_RDR_DEV_OPER_STATUS_PRIOR:
// do nothing
break;
case EPCG_RDR_DEV_OPER_STATE_ENABLE:
setValue(new Integer32(((ReaderDevice)objects[0]).getOperStatusAlarmControl().getEnabled() ? 1 : 2));
break;
case EPCG_RDR_DEV_OPER_NOTIF_FROM_STATE:
setValue(SnmpUtil.operStateToBITS(((ReaderDevice)objects[0]).getOperStatusAlarmControl().getTriggerFromState()));
break;
case EPCG_RDR_DEV_OPER_NOTIF_TO_STATE:
setValue(SnmpUtil.operStateToBITS(((ReaderDevice)objects[0]).getOperStatusAlarmControl().getTriggerToState()));
break;
case EPCG_RDR_DEV_OPER_NOTIF_STATE_LEVEL:
setValue(new Integer32(((ReaderDevice)objects[0]).getOperStatusAlarmControl().getLevel().toInt()));
break;
case EPCG_RDR_DEV_OPER_STATE_SUPPRESS_INTERVAL:
setValue(new UnsignedInteger32(((ReaderDevice)objects[0]).getOperStatusAlarmControl().getSuppressInterval()));
break;
case EPCG_RDR_DEV_OPER_STATE_SUPPRESSIONS:
setValue(new Counter32(ReaderDevice.getOperStateSuppressions()));
break;
case EPCG_RDR_DEV_FREE_MEMORY:
setValue(new Gauge32(((ReaderDevice)objects[0]).getFreeMemory()));
break;
case EPCG_RDR_DEV_FREE_MEMORY_NOTIF_ENABLE:
setValue(new Integer32(((ReaderDevice)objects[0]).getFreeMemoryAlarmControl().getEnabled() ? 1 : 2));
break;
case EPCG_RDR_DEV_FREE_MEMORY_NOTIF_LEVEL:
setValue(new Integer32(((ReaderDevice)objects[0]).getFreeMemoryAlarmControl().getLevel().toInt()));
break;
case EPCG_RDR_DEV_FREE_MEMORY_ONSET_THRESHOLD:
setValue(new UnsignedInteger32(((ReaderDevice)objects[0]).getFreeMemoryAlarmControl().getAlarmThreshold()));
break;
case EPCG_RDR_DEV_FREE_MEMORY_ABATE_THRESHOLD:
setValue(new UnsignedInteger32(((ReaderDevice)objects[0]).getFreeMemoryAlarmControl().getRearmThreshold()));
break;
case EPCG_RDR_DEV_FREE_MEMORY_STATUS:
readerDevice = ((ReaderDevice)objects[0]);
setValue(new Integer32(readerDevice.getFreeMemory() < readerDevice.getFreeMemoryAlarmControl().getAlarmThreshold() ? 1 : 2));
break;
case EPCG_RDR_DEV_MEM_STATE_SUPPRESS_INTERVAL:
setValue(new UnsignedInteger32(((ReaderDevice)objects[0]).getFreeMemoryAlarmControl().getSuppressInterval()));
break;
case EPCG_RDR_DEV_MEM_STATE_SUPPRESSIONS:
setValue(new Counter32(ReaderDevice.getMemStateSuppressions()));
break;
// case EPCG_READ_POINT_PRIOR_OPER_STATUS:
// // do nothing
// break;
// case EPCG_READ_POINT_OPER_STATE_SUPPRESS_INTERVAL:
// // ...
// break;
// case EPCG_READ_POINT_OPER_STATE_SUPPRESSIONS:
// setValue(new Counter32(ReadPoint.getOperStateSuppressions()));
// break;
// case EPCG_ANT_RD_PNT_SUPPRESS_INTERVAL:
// // ...
// break;
// case EPCG_IO_PORT_OPER_STATUS_PRIOR:
// // do nothing
// break;
// case EPCG_IO_PORT_OPER_STATE_SUPPRESS_INTERVAL:
// // ...
// break;
// case EPCG_IO_PORT_OPER_STATE_SUPPRESSIONS:
// setValue(new Counter32(IOPort.getOperStateSuppressions()));
// break;
// case EPCG_SRC_OPER_PRIOR_STATUS:
// // do nothing
// break;
// case EPCG_SRC_OPER_STATE_SUPPRESS_INTERVAL:
// // ...
// break;
// case EPCG_SRC_OPER_STATE_SUPPRESSIONS:
// setValue(new Counter32(Source.getOperStateSuppressions()));
// break;
// case EPCG_NOTIF_CHAN_OPER_STATUS_PRIOR:
// // do nothing
// break;
// case EPCG_NOTIF_CHAN_OPER_STATE_SUPPRESS_INTERVAL:
// // ...
// break;
// case EPCG_NOTIF_CHAN_OPER_STATE_SUPPRESSIONS:
// setValue(new Counter32(NotificationChannel.getOperStateSuppressions()));
// break;
case SYS_DESCR:
readerDevice = (ReaderDevice)objects[0];
String descr =
"Manufacturer: "
+ readerDevice.getManufacturer()
+ ", Model: "
+ readerDevice.getModel()
+ ", Manufacturer Description: "
+ readerDevice.getManufacturerDescription();
setValue(new OctetString(descr));
break;
case SYS_LOCATION:
setValue(new OctetString(((ReaderDevice)objects[0]).getLocationDescription()));
break;
case SYS_CONTACT:
setValue(new OctetString(((ReaderDevice)objects[0]).getContact()));
break;
case SYS_UP_TIME:
setValue(new TimeTicks(((ReaderDevice)objects[0]).getTimeTicks()));
break;
case SYS_NAME:
setValue(new OctetString(((ReaderDevice)objects[0]).getName()));
break;
}
}
return super.getValue();
}
/**
* Sets the value of this scalar managed object without checking it for the
* correct syntax.
*
* @param value
* A <code>Variable</code> with the same syntax defined for
* this scalar object (not checked)
* @return A SNMP error code (zero indicating success by default)
*/
@Override
public int setValue(Variable value) {
switch (type) {
case EPCG_RDR_DEV_REBOOT:
boolean reboot = ((Integer32)value).toInt() == 1;
if (reboot) {
try {
((ReaderDevice)(objects[0])).reboot();
} catch (ReaderProtocolException rpe) {
log.error(rpe.getMessage());
}
}
break;
case EPCG_RDR_DEV_RESET_STATISTICS:
boolean resetStatistics = ((Integer32) value).toInt() == 1;
if (resetStatistics) {
((ReaderDevice) (objects[0])).resetStatistics();
MOScalar resetTimestamp = SnmpUtil.findMOScalar(EpcglobalReaderMib.oidEpcgRdrDevResetTimestamp);
if (resetTimestamp != null) {
resetTimestamp.setValue(SnmpUtil.dateToOctetString(new Date()));
}
}
break;
case EPCG_RDR_DEV_OPER_STATE_ENABLE:
((ReaderDevice) (objects[0])).getOperStatusAlarmControl().setEnabled(((Integer32)value).toInt() == 1);
break;
case EPCG_RDR_DEV_OPER_NOTIF_FROM_STATE:
((ReaderDevice) (objects[0])).getOperStatusAlarmControl().setTriggerFromState(SnmpUtil.bitsToOperState((OctetString)value));
break;
case EPCG_RDR_DEV_OPER_NOTIF_TO_STATE:
((ReaderDevice) (objects[0])).getOperStatusAlarmControl().setTriggerToState(SnmpUtil.bitsToOperState((OctetString)value));
break;
case EPCG_RDR_DEV_OPER_NOTIF_STATE_LEVEL:
((ReaderDevice) (objects[0])).getOperStatusAlarmControl().setLevel(AlarmLevel.intToEnum(((Integer32)value).toInt()));
break;
case EPCG_RDR_DEV_OPER_STATE_SUPPRESS_INTERVAL:
((ReaderDevice) (objects[0])).getOperStatusAlarmControl().setSuppressInterval(((UnsignedInteger32)value).toInt());
break;
case EPCG_RDR_DEV_FREE_MEMORY_NOTIF_ENABLE:
((ReaderDevice) (objects[0])).getFreeMemoryAlarmControl().setEnabled(((Integer32)value).toInt() == 1);
break;
case EPCG_RDR_DEV_FREE_MEMORY_NOTIF_LEVEL:
((ReaderDevice) (objects[0])).getFreeMemoryAlarmControl().setLevel(AlarmLevel.intToEnum(((Integer32)value).toInt()));
break;
case EPCG_RDR_DEV_FREE_MEMORY_ONSET_THRESHOLD:
((ReaderDevice) (objects[0])).getFreeMemoryAlarmControl().setAlarmThreshold(((UnsignedInteger32)value).toInt());
break;
case EPCG_RDR_DEV_FREE_MEMORY_ABATE_THRESHOLD:
((ReaderDevice) (objects[0])).getFreeMemoryAlarmControl().setRearmThreshold(((UnsignedInteger32)value).toInt());
break;
case EPCG_RDR_DEV_MEM_STATE_SUPPRESS_INTERVAL:
((ReaderDevice) (objects[0])).getFreeMemoryAlarmControl().setSuppressInterval(((UnsignedInteger32)value).toInt());
break;
case SYS_CONTACT:
((ReaderDevice) (objects[0])).setContact(((OctetString)value).toString());
break;
case SYS_LOCATION:
((ReaderDevice) (objects[0])).setLocationDescription(((OctetString)value).toString());
break;
case SYS_NAME:
((ReaderDevice) (objects[0])).setName(((OctetString)value).toString());
break;
}
return super.setValue(value);
}
/**
* Forces a refresh.
*/
public void forceRefresh() {
lastRefreshTime = 0;
}
/**
* Sets the refresh time in ms.
*
* @param refreshTimeInMs
* Refresh time in ms
*/
public void setRefreshTime(long refreshTimeInMs) {
this.refreshTimeInMs = refreshTimeInMs;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -