Skip to content

Commit

Permalink
Moved string manipulation & VariableBinding instantiation into snmp p…
Browse files Browse the repository at this point in the history
…rotocol classes.
  • Loading branch information
dmccoystephenson committed Sep 11, 2023
1 parent 947e0b5 commit e01fbc1
Show file tree
Hide file tree
Showing 6 changed files with 524 additions and 257 deletions.
115 changes: 20 additions & 95 deletions jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/pdm/PdmUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import org.snmp4j.PDU;
import org.snmp4j.ScopedPDU;
import org.snmp4j.smi.Integer32;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.VariableBinding;

import us.dot.its.jpo.ode.plugin.j2735.J2735ProbeDataManagment;
Expand All @@ -39,75 +37,20 @@ public static ScopedPDU createPDU(J2735ProbeDataManagment params) {
pdu.setType(PDU.SET);

// Add singular items to PDU
VariableBinding rsuPDMSampleStart = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_sample_start_oid),
new Integer32(params.getSampleStart())
);

VariableBinding rsuPDMSampleEnd = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_sample_end_oid),
new Integer32(params.getSampleEnd())
);

VariableBinding rsuPDMDirections = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_directions_oid),
new Integer32(params.getDirections())
);

VariableBinding rsuPDMTermChoice = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_term_choice_oid),
new Integer32(params.getTermChoice())
);

VariableBinding rsuPDMTermTime = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_term_time_oid),
new Integer32(params.getTermTime())
);

VariableBinding rsuPDMTermDistance = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_term_distance_oid),
new Integer32(params.getTermDistance())
);

VariableBinding rsuPDMSnapshotChoice = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_snapshot_choice_oid),
new Integer32(params.getSnapshotChoice())
);

VariableBinding rsuPDMMinSnapshotTime = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_min_snapshot_time_oid),
new Integer32(params.getMinSnapshotTime())
);

VariableBinding rsuPDMMaxSnapshotTime = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_max_snapshot_time_oid),
new Integer32(params.getMaxSnapshotTime())
);

VariableBinding rsuPDMMinSnapshotDistance = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_min_snapshot_distance_oid),
new Integer32(params.getMinSnapshotDistance())
);

VariableBinding rsuPDMMaxSnapshotDistance = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_max_snapshot_distance_oid),
new Integer32(params.getMaxSnapshotDistance())
);

VariableBinding rsuPDMSnapshotMinSpeed = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_snapshot_min_speed_oid),
new Integer32(params.getSnapshotMinSpeed())
);

VariableBinding rsuPDMSnapshotMaxSpeed = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_snapshot_max_speed_oid),
new Integer32(params.getSnapshotMaxSpeed())
);

VariableBinding rsuPDMTxInterval = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_tx_interval_oid),
new Integer32(params.getTxInterval())
);
VariableBinding rsuPDMSampleStart = SnmpFourDot1Protocol.getVbRsuPdmSampleStart(params.getSampleStart());
VariableBinding rsuPDMSampleEnd = SnmpFourDot1Protocol.getVbRsuPdmSampleEnd(params.getSampleEnd());
VariableBinding rsuPDMDirections = SnmpFourDot1Protocol.getVbRsuPdmDirections(params.getDirections());
VariableBinding rsuPDMTermChoice = SnmpFourDot1Protocol.getVbRsuPdmTermChoice(params.getTermChoice());
VariableBinding rsuPDMTermTime = SnmpFourDot1Protocol.getVbRsuPdmTermTime(params.getTermTime());
VariableBinding rsuPDMTermDistance = SnmpFourDot1Protocol.getVbRsuPdmTermDistance(params.getTermDistance());
VariableBinding rsuPDMSnapshotChoice = SnmpFourDot1Protocol.getVbRsuPdmSnapshotChoice(params.getSnapshotChoice());
VariableBinding rsuPDMMinSnapshotTime = SnmpFourDot1Protocol.getVbRsuPdmMinSnapshotTime(params.getMinSnapshotTime());
VariableBinding rsuPDMMaxSnapshotTime = SnmpFourDot1Protocol.getVbRsuPdmMaxSnapshotTime(params.getMaxSnapshotTime());
VariableBinding rsuPDMMinSnapshotDistance = SnmpFourDot1Protocol.getVbRsuPdmMinSnapshotDistance(params.getMinSnapshotDistance());
VariableBinding rsuPDMMaxSnapshotDistance = SnmpFourDot1Protocol.getVbRsuPdmMaxSnapshotDistance(params.getMaxSnapshotDistance());
VariableBinding rsuPDMSnapshotMinSpeed = SnmpFourDot1Protocol.getVbRsuPdmSnapshotMinSpeed(params.getSnapshotMinSpeed());
VariableBinding rsuPDMSnapshotMaxSpeed = SnmpFourDot1Protocol.getVbRsuPdmSnapshotMaxSpeed(params.getSnapshotMaxSpeed());
VariableBinding rsuPDMTxInterval = SnmpFourDot1Protocol.getVbRsuPdmTxInterval(params.getTxInterval());

pdu.add(rsuPDMSampleStart);
pdu.add(rsuPDMSampleEnd);
Expand All @@ -128,30 +71,12 @@ public static ScopedPDU createPDU(J2735ProbeDataManagment params) {

for (int index = 0; index < params.getVehicleStatusRequestList().length; index++) {

VariableBinding rsuPDMVSReqTag = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_vs_req_tag_oid.replace("{}", String.valueOf(index))),
new Integer32(params.getVehicleStatusRequestList()[index].getTag())
);
VariableBinding rsuPDMVSReqSubTag = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_vs_req_sub_tag_oid.replace("{}", String.valueOf(index))),
new Integer32(params.getVehicleStatusRequestList()[index].getSubTag())
);
VariableBinding rsuPDMVSReqLessThenValue = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_vs_req_less_then_oid.replace("{}", String.valueOf(index))),
new Integer32(params.getVehicleStatusRequestList()[index].getLessThenValue())
);
VariableBinding rsuPDMVSReqMoreThenValue = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_vs_req_more_then_oid.replace("{}", String.valueOf(index))),
new Integer32(params.getVehicleStatusRequestList()[index].getMoreThenValue())
);
VariableBinding rsuPDMVSReqSendAll = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_vs_req_send_all_oid.replace("{}", String.valueOf(index))),
new Integer32(params.getVehicleStatusRequestList()[index].getSendAll())
);
VariableBinding rsuPDMVSReqStatus = new VariableBinding(
new OID(SnmpFourDot1Protocol.rsu_pdm_vs_req_status_oid.replace("{}", String.valueOf(index))),
new Integer32(params.getVehicleStatusRequestList()[index].getStatus())
);
VariableBinding rsuPDMVSReqTag = SnmpFourDot1Protocol.getVbRsuPdmVsReqTag(index, params.getVehicleStatusRequestList()[index].getTag());
VariableBinding rsuPDMVSReqSubTag = SnmpFourDot1Protocol.getVbRsuPdmVsReqSubTag(index, params.getVehicleStatusRequestList()[index].getSubTag());
VariableBinding rsuPDMVSReqLessThenValue = SnmpFourDot1Protocol.getVbRsuPdmVsReqLessThen(index, params.getVehicleStatusRequestList()[index].getLessThenValue());
VariableBinding rsuPDMVSReqMoreThenValue = SnmpFourDot1Protocol.getVbRsuPdmVsReqMoreThen(index, params.getVehicleStatusRequestList()[index].getMoreThenValue());
VariableBinding rsuPDMVSReqSendAll = SnmpFourDot1Protocol.getVbRsuPdmVsReqSendAll(index, params.getVehicleStatusRequestList()[index].getSendAll());
VariableBinding rsuPDMVSReqStatus = SnmpFourDot1Protocol.getVbRsuPdmVsReqStatus(index, params.getVehicleStatusRequestList()[index].getStatus());

pdu.add(rsuPDMVSReqTag);
pdu.add(rsuPDMVSReqSubTag);
Expand Down
Loading

0 comments on commit e01fbc1

Please sign in to comment.