|
@@ -17,6 +17,7 @@ import io.netty.channel.ChannelFuture;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
|
|
|
+import java.util.Calendar;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class LoginDeviceService {
|
|
public class LoginDeviceService {
|
|
@@ -41,25 +42,28 @@ public class LoginDeviceService {
|
|
|
|
|
|
|
|
// OBU Non Crypt 데이터 요청 Subscription
|
|
// OBU Non Crypt 데이터 요청 Subscription
|
|
|
if (isObuNonCrypt) {
|
|
if (isObuNonCrypt) {
|
|
|
- requestPublicationNonCryptObu(obj, channel);
|
|
|
|
|
|
|
+ log.info("initLoginDevice.isObuNonCrypt. {}, {}, {}", obj.getRSE_CTLR_NMBR(), obj.getRSE_CTLR_IP(), obj.getRSE_MCU_ID());
|
|
|
|
|
+ //requestPublicationNonCryptObu(obj, channel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// DSRC 상태정보 요청 Subscription
|
|
// DSRC 상태정보 요청 Subscription
|
|
|
if (isDsrcStatus) {
|
|
if (isDsrcStatus) {
|
|
|
- requestSubscriptions(obj, channel, subscriptionStatusCycle, 1);
|
|
|
|
|
|
|
+ log.info("initLoginDevice.isDsrcStatus. {}, {}, {}", obj.getRSE_CTLR_NMBR(), obj.getRSE_CTLR_IP(), obj.getRSE_MCU_ID());
|
|
|
|
|
+ //requestSubscriptions(obj, channel, subscriptionStatusCycle, 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// OBU 교통정보 요청 Subscription
|
|
// OBU 교통정보 요청 Subscription
|
|
|
if (isTraffic) {
|
|
if (isTraffic) {
|
|
|
|
|
+ log.info("initLoginDevice.isTraffic. {}, {}, {}", obj.getRSE_CTLR_NMBR(), obj.getRSE_CTLR_IP(), obj.getRSE_MCU_ID());
|
|
|
requestSubscriptions(obj, channel, 0, 2);
|
|
requestSubscriptions(obj, channel, 0, 2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// DSRC Antenna enable Publication
|
|
// DSRC Antenna enable Publication
|
|
|
- if (antennaCnt > 0) {
|
|
|
|
|
- for (int antennaId = 1; antennaId <= antennaCnt; antennaId++) {
|
|
|
|
|
- requestSubscriptionDeviceCommand(obj, channel, antennaId, eControlCommand.ControlCommand_Wireless_Start.getValue());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if (antennaCnt > 0) {
|
|
|
|
|
+// for (int antennaId = 1; antennaId <= antennaCnt; antennaId++) {
|
|
|
|
|
+// requestSubscriptionDeviceCommand(obj, channel, antennaId, eControlCommand.ControlCommand_Wireless_Start.getValue());
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -80,6 +84,17 @@ public class LoginDeviceService {
|
|
|
log.info("LoginDeviceService.requestSubscriptions: {}, {}, registeredUpdateDelayQty: {}, subscriptionsType: {}", obj.getID(), obj.getRSE_ID(), registeredUpdateDelayQty, subscriptionsType);
|
|
log.info("LoginDeviceService.requestSubscriptions: {}, {}, registeredUpdateDelayQty: {}, subscriptionsType: {}", obj.getID(), obj.getRSE_ID(), registeredUpdateDelayQty, subscriptionsType);
|
|
|
|
|
|
|
|
int[] messageId = {1, 0, 15784, 4, 0, 7};
|
|
int[] messageId = {1, 0, 15784, 4, 0, 7};
|
|
|
|
|
+// pObject->numids = 6;
|
|
|
|
|
+// pObject->subid[0] = 1;
|
|
|
|
|
+// pObject->subid[1] = 0;
|
|
|
|
|
+// pObject->subid[2] = 15784;
|
|
|
|
|
+// switch (id)
|
|
|
|
|
+// {
|
|
|
|
|
+// case itMultimediaData: pObject->subid[3] = 5; pObject->subid[4] = 0; pObject->subid[5] = 1; break;
|
|
|
|
|
+// case itControlDevice: pObject->subid[3] = 4; pObject->subid[4] = 0; pObject->subid[5] = 7; break;
|
|
|
|
|
+// case itObuGatherInfo: pObject->subid[3] = 8; pObject->subid[4] = 0; pObject->subid[5] = 8; break;
|
|
|
|
|
+// default: break;
|
|
|
|
|
+// }
|
|
|
int subscribeSerialNbr = obj.getSeq().nextValue();
|
|
int subscribeSerialNbr = obj.getSeq().nextValue();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -131,7 +146,8 @@ public class LoginDeviceService {
|
|
|
subscriptionData.setDatexSubscribeStatusCd(new BerEnum(0)); // 0: New, 1: Update
|
|
subscriptionData.setDatexSubscribeStatusCd(new BerEnum(0)); // 0: New, 1: Update
|
|
|
subscriptionData.setDatexSubscribeMode(subscriptionMode);
|
|
subscriptionData.setDatexSubscribeMode(subscriptionMode);
|
|
|
subscriptionData.setDatexSubscribePublishFormatCd(new BerEnum(3)); // 0: other, 1: ftp, 2: tftp, 3: dataPacket
|
|
subscriptionData.setDatexSubscribePublishFormatCd(new BerEnum(3)); // 0: other, 1: ftp, 2: tftp, 3: dataPacket
|
|
|
- subscriptionData.setDatexSubscriptionPriorityNbr(new BerInteger(1));
|
|
|
|
|
|
|
+ //subscriptionData.setDatexSubscriptionPriorityNbr(new BerInteger(1));
|
|
|
|
|
+ subscriptionData.setDatexSubscriptionPriorityNbr(new BerInteger(10));
|
|
|
subscriptionData.setDatexSubscribeGuaranteeBool(new BerBoolean(true));
|
|
subscriptionData.setDatexSubscribeGuaranteeBool(new BerBoolean(true));
|
|
|
subscriptionData.setDatexSubscribePdu(endApplicationMessage);
|
|
subscriptionData.setDatexSubscribePdu(endApplicationMessage);
|
|
|
|
|
|
|
@@ -285,47 +301,297 @@ public class LoginDeviceService {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 클라이언트 모드로 동작시 Initiate 수신시 로그인 정보를 전송한다.
|
|
|
|
|
+ * @param obj
|
|
|
|
|
+ * @param channel
|
|
|
|
|
+ * @param runningConfig
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
public boolean requestLogin(TbRseCtlr obj, Channel channel, RunningConfig runningConfig) {
|
|
public boolean requestLogin(TbRseCtlr obj, Channel channel, RunningConfig runningConfig) {
|
|
|
|
|
|
|
|
- log.info("LoginResponse.requestLogin");
|
|
|
|
|
|
|
+ log.info("LoginResponse.requestLogin: {}, {}, {}", obj.getRSE_CTLR_NMBR(), obj.getRSE_CTLR_IP(), obj.getRSE_MCU_ID());
|
|
|
|
|
+
|
|
|
|
|
+ int dataPacketNumber = 0; //obj.getSeq().nextValue()
|
|
|
|
|
+ int dataPacketPriorityNumber = 0;
|
|
|
|
|
+ String serverDomainName = runningConfig.getServerDomainName();
|
|
|
|
|
+ String destinationTxt = obj.getRSE_MCU_ID();
|
|
|
|
|
+ String loginUserNameTxt = "";
|
|
|
|
|
+ String loginPasswordTxt = "";
|
|
|
|
|
|
|
|
Login login = new Login();
|
|
Login login = new Login();
|
|
|
- login.setDatexSenderTxt(new BerUTF8String(runningConfig.getServerDomainName()));
|
|
|
|
|
- login.setDatexDestinationTxt(new BerUTF8String(runningConfig.getServerDomainName()));
|
|
|
|
|
- login.setDatexLoginUserNameTxt(new BerUTF8String(runningConfig.getServerAuthUser()));
|
|
|
|
|
- login.setDatexLoginPasswordTxt(new BerUTF8String(runningConfig.getServerAuthPassword()));
|
|
|
|
|
|
|
+ login.setDatexSenderTxt(new BerUTF8String(serverDomainName));
|
|
|
|
|
+ login.setDatexDestinationTxt(new BerUTF8String(destinationTxt));
|
|
|
|
|
+ login.setDatexLoginUserNameTxt(new BerUTF8String(loginUserNameTxt));
|
|
|
|
|
+ login.setDatexLoginPasswordTxt(new BerUTF8String(loginPasswordTxt));
|
|
|
login.setDatexLoginHeartbeatDurationMaxQty(new BerInteger(120));
|
|
login.setDatexLoginHeartbeatDurationMaxQty(new BerInteger(120));
|
|
|
- login.setDatexLoginResponseTimeOutQty(new BerInteger(5));
|
|
|
|
|
|
|
+ login.setDatexLoginResponseTimeOutQty(new BerInteger(30));
|
|
|
login.setDatexLoginInitiatorCd(new BerEnum(1));
|
|
login.setDatexLoginInitiatorCd(new BerEnum(1));
|
|
|
login.setDatexLoginDatagramSizeQty(new BerInteger(2048));
|
|
login.setDatexLoginDatagramSizeQty(new BerInteger(2048));
|
|
|
- int[] encodingRules = {2, 1, 1};
|
|
|
|
|
|
|
+ int[] encodingRules = {2, 1};
|
|
|
Login.DatexLoginEncodingRulesId loginEncodingRulesId = new Login.DatexLoginEncodingRulesId();
|
|
Login.DatexLoginEncodingRulesId loginEncodingRulesId = new Login.DatexLoginEncodingRulesId();
|
|
|
loginEncodingRulesId.getBerObjectIdentifier().add(new BerObjectIdentifier(encodingRules));
|
|
loginEncodingRulesId.getBerObjectIdentifier().add(new BerObjectIdentifier(encodingRules));
|
|
|
login.setDatexLoginEncodingRulesId(loginEncodingRulesId);
|
|
login.setDatexLoginEncodingRulesId(loginEncodingRulesId);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
byte[] auth = {(byte) eAuthInfo.AI_Login.getValue() };
|
|
byte[] auth = {(byte) eAuthInfo.AI_Login.getValue() };
|
|
|
PDUs loginPdu = new PDUs();
|
|
PDUs loginPdu = new PDUs();
|
|
|
loginPdu.setLogin(login);
|
|
loginPdu.setLogin(login);
|
|
|
|
|
|
|
|
- HeaderOptions headerOptions = DsrcAsn1Utils.getDefaultOptions();
|
|
|
|
|
|
|
+ HeaderOptions headerOptions = new HeaderOptions();
|
|
|
|
|
+ Time tm = new Time();
|
|
|
|
|
+ Time.TimeSecondFractions tmFac = new Time.TimeSecondFractions();
|
|
|
|
|
+ Time.TimeTimezone tmZon = new Time.TimeTimezone();
|
|
|
|
|
+ Calendar currTm = Calendar.getInstance();
|
|
|
|
|
+ tm.setTimeYearQty(new BerInteger(currTm.get(Calendar.YEAR)));
|
|
|
|
|
+ tm.setTimeMonthQty(new BerInteger(currTm.get(Calendar.MONTH)+1));
|
|
|
|
|
+ tm.setTimeDayQty(new BerInteger(currTm.get(Calendar.DATE)));
|
|
|
|
|
+ tm.setTimeHourQty(new BerInteger(currTm.get(Calendar.HOUR_OF_DAY)));
|
|
|
|
|
+ tm.setTimeMinuteQty(new BerInteger(currTm.get(Calendar.MINUTE)));
|
|
|
|
|
+ tm.setTimeSecondQty(new BerInteger(currTm.get(Calendar.SECOND)));
|
|
|
|
|
+ tmFac.setMilliseconds(new BerInteger(currTm.get(Calendar.MILLISECOND)));
|
|
|
|
|
+ tm.setTimeSecondFractions(tmFac);
|
|
|
|
|
+ headerOptions.setDatexDataPacketTime(tm);
|
|
|
|
|
+
|
|
|
C2CAuthenticatedMessage c2c = new C2CAuthenticatedMessage();
|
|
C2CAuthenticatedMessage c2c = new C2CAuthenticatedMessage();
|
|
|
c2c.setDatexAuthenticationInfoText(new BerOctetString(auth));
|
|
c2c.setDatexAuthenticationInfoText(new BerOctetString(auth));
|
|
|
- c2c.setDatexDataPacketNumber(new BerInteger(obj.getSeq().nextValue()));
|
|
|
|
|
- c2c.setDatexDataPacketPriorityNumber(new BerInteger(1));
|
|
|
|
|
|
|
+ c2c.setDatexDataPacketNumber(new BerInteger(dataPacketNumber));
|
|
|
|
|
+ c2c.setDatexDataPacketPriorityNumber(new BerInteger(dataPacketPriorityNumber));
|
|
|
c2c.setOptions(headerOptions);
|
|
c2c.setOptions(headerOptions);
|
|
|
c2c.setPdu(loginPdu);
|
|
c2c.setPdu(loginPdu);
|
|
|
|
|
|
|
|
- obj.setHeaderOptions(DsrcAsn1Utils.swapHeaderOptions(headerOptions));
|
|
|
|
|
-
|
|
|
|
|
ChannelFuture f = channel.writeAndFlush(c2c);
|
|
ChannelFuture f = channel.writeAndFlush(c2c);
|
|
|
f.awaitUninterruptibly();
|
|
f.awaitUninterruptibly();
|
|
|
if (f.isDone() || f.isSuccess()) {
|
|
if (f.isDone() || f.isSuccess()) {
|
|
|
- log.info("LoginDeviceService.requestLogin: {}, {}, send ok", obj.getID(), obj.getRSE_ID());
|
|
|
|
|
|
|
+ obj.setHeaderOptions(DsrcAsn1Utils.swapHeaderOptions(headerOptions));
|
|
|
|
|
+ obj.setLogin(login);
|
|
|
|
|
+ log.info("LoginResponse.requestLogin: {}, {}, {}, send ok.", obj.getRSE_CTLR_NMBR(), obj.getRSE_CTLR_IP(), obj.getRSE_MCU_ID());
|
|
|
} else {
|
|
} else {
|
|
|
log.error("LoginDeviceService.requestLogin: {}, {}, send failed.", obj.getID(), obj.getRSE_ID());
|
|
log.error("LoginDeviceService.requestLogin: {}, {}, send failed.", obj.getID(), obj.getRSE_ID());
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// public boolean requestLogin2(TbRseCtlr obj, Channel channel, RunningConfig runningConfig) {
|
|
|
|
|
+//
|
|
|
|
|
+// log.info("LoginResponse.requestLogin: {}, {}, {}", obj.getRSE_CTLR_NMBR(), obj.getRSE_CTLR_IP(), obj.getRSE_MCU_ID());
|
|
|
|
|
+//
|
|
|
|
|
+// int dataPacketNumber = 0; //obj.getSeq().nextValue()
|
|
|
|
|
+// int dataPacketPriorityNumber = 0;
|
|
|
|
|
+//
|
|
|
|
|
+// Login login = new Login();
|
|
|
|
|
+// login.setDatexSenderTxt(new BerUTF8String(runningConfig.getServerDomainName()));
|
|
|
|
|
+// login.setDatexDestinationTxt(new BerUTF8String(obj.getRSE_MCU_ID()));
|
|
|
|
|
+// login.setDatexLoginUserNameTxt(new BerUTF8String(runningConfig.getServerAuthUser()));
|
|
|
|
|
+// login.setDatexLoginPasswordTxt(new BerUTF8String(runningConfig.getServerAuthPassword()));
|
|
|
|
|
+// login.setDatexLoginHeartbeatDurationMaxQty(new BerInteger(120));
|
|
|
|
|
+// login.setDatexLoginResponseTimeOutQty(new BerInteger(30));
|
|
|
|
|
+// login.setDatexLoginInitiatorCd(new BerEnum(1));
|
|
|
|
|
+// login.setDatexLoginDatagramSizeQty(new BerInteger(2048));
|
|
|
|
|
+// int[] encodingRules = {2, 1, 1};
|
|
|
|
|
+// Login.DatexLoginEncodingRulesId loginEncodingRulesId = new Login.DatexLoginEncodingRulesId();
|
|
|
|
|
+// loginEncodingRulesId.getBerObjectIdentifier().add(new BerObjectIdentifier(encodingRules));
|
|
|
|
|
+// login.setDatexLoginEncodingRulesId(loginEncodingRulesId);
|
|
|
|
|
+//
|
|
|
|
|
+// byte[] auth = {(byte) eAuthInfo.AI_Login.getValue() };
|
|
|
|
|
+// PDUs loginPdu = new PDUs();
|
|
|
|
|
+// loginPdu.setLogin(login);
|
|
|
|
|
+//
|
|
|
|
|
+// HeaderOptions headerOptions = DsrcAsn1Utils.getDefaultOptions();
|
|
|
|
|
+// C2CAuthenticatedMessage c2c = new C2CAuthenticatedMessage();
|
|
|
|
|
+// c2c.setDatexAuthenticationInfoText(new BerOctetString(auth));
|
|
|
|
|
+// c2c.setDatexDataPacketNumber(new BerInteger(dataPacketNumber));
|
|
|
|
|
+// c2c.setDatexDataPacketPriorityNumber(new BerInteger(dataPacketPriorityNumber));
|
|
|
|
|
+// c2c.setOptions(headerOptions);
|
|
|
|
|
+// c2c.setPdu(loginPdu);
|
|
|
|
|
+//
|
|
|
|
|
+// ChannelFuture f = channel.writeAndFlush(c2c);
|
|
|
|
|
+// f.awaitUninterruptibly();
|
|
|
|
|
+// if (f.isDone() || f.isSuccess()) {
|
|
|
|
|
+// obj.setHeaderOptions(DsrcAsn1Utils.swapHeaderOptions(headerOptions));
|
|
|
|
|
+// obj.setLogin(login);
|
|
|
|
|
+// log.info("LoginResponse.requestLogin: {}, {}, {}, send ok.", obj.getRSE_CTLR_NMBR(), obj.getRSE_CTLR_IP(), obj.getRSE_MCU_ID());
|
|
|
|
|
+// } else {
|
|
|
|
|
+// log.error("LoginDeviceService.requestLogin: {}, {}, send failed.", obj.getID(), obj.getRSE_ID());
|
|
|
|
|
+// }
|
|
|
|
|
+// return true;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * OBU 수집 정보 요청 등록(이벤트 방식)
|
|
|
|
|
+ * @param obj
|
|
|
|
|
+ * @param channel
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public boolean requestObuGatherInfo(TbRseCtlr obj, Channel channel) {
|
|
|
|
|
+
|
|
|
|
|
+ log.info("LoginDeviceService.requestObuGatherInfo: {}, {}", obj.getID(), obj.getRSE_ID());
|
|
|
|
|
+
|
|
|
|
|
+ int[] messageId = {1, 0, 15784, 8, 0, 8};
|
|
|
|
|
+ int dataPacketNumber = 1; //obj.getSeq().nextValue()
|
|
|
|
|
+ int dataPacketPriorityNumber = 0;
|
|
|
|
|
+ int datexSubscriptionPriorityNbr = 10;
|
|
|
|
|
+ int subscribeSerialNbr = 0;
|
|
|
|
|
+ try {
|
|
|
|
|
+ byte[] obuIdNumber = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
|
|
|
|
+ byte[] vehicleType = {0};
|
|
|
|
|
+ byte[] obuType = {0};
|
|
|
|
|
+ byte[] generationDate = {0,0,0,0};
|
|
|
|
|
+ byte[] generationTime = {0,0,0};
|
|
|
|
|
+
|
|
|
|
|
+ OBUGatherInfoList lists = new OBUGatherInfoList();
|
|
|
|
|
+ OBUGatherInfo gatherInfo = new OBUGatherInfo();
|
|
|
|
|
+ gatherInfo.setObuIdNumber(new BerOctetString(obuIdNumber));
|
|
|
|
|
+ BeaconID beaconID = new BeaconID();
|
|
|
|
|
+ beaconID.setManufacturerid(new BerInteger(obj.getManufacturerid()));
|
|
|
|
|
+ beaconID.setIndividualid(new BerInteger(obj.getIndividualid()));
|
|
|
|
|
+ gatherInfo.setRseIDNumber(beaconID);
|
|
|
|
|
+ gatherInfo.setVehicleType(new BerOctetString(vehicleType));
|
|
|
|
|
+ gatherInfo.setObuType(new BerOctetString(obuType));
|
|
|
|
|
+ gatherInfo.setGenerationDate(new BerOctetString(generationDate));
|
|
|
|
|
+ gatherInfo.setGenerationTime(new BerOctetString(generationTime));
|
|
|
|
|
+ lists.getOBUGatherInfo().add(gatherInfo);
|
|
|
|
|
+
|
|
|
|
|
+ byte[] controlId = { (byte)4 };
|
|
|
|
|
+ ReverseByteArrayOutputStream msgBuff = new ReverseByteArrayOutputStream(1024);
|
|
|
|
|
+ lists.encode(msgBuff);
|
|
|
|
|
+ ControlDevice controlDevice = new ControlDevice();
|
|
|
|
|
+ controlDevice.setVpbdControlID(new BerOctetString(controlId));
|
|
|
|
|
+ controlDevice.setVpbdControlDeviceData(new BerOctetString(msgBuff.getArray()));
|
|
|
|
|
+
|
|
|
|
|
+ Registered registered = new Registered();
|
|
|
|
|
+ Registered.Continuous continuous = new Registered.Continuous();
|
|
|
|
|
+ SubscriptionMode subscriptionMode = new SubscriptionMode();
|
|
|
|
|
+
|
|
|
|
|
+ continuous.setDatexRegisteredUpdateDelayQty(new BerInteger(0));
|
|
|
|
|
+ continuous.setDatexRegisteredStartTime(DsrcAsn1Utils.getRegisterStartTime());
|
|
|
|
|
+ continuous.setDatexRegisteredEndTime(DsrcAsn1Utils.getRegisterEndTime());
|
|
|
|
|
+ registered.setContinuous(continuous);
|
|
|
|
|
+ subscriptionMode.setEventDriven(registered);
|
|
|
|
|
+
|
|
|
|
|
+ // EndApplicationMessage set
|
|
|
|
|
+ EndApplicationMessage endApplicationMessage = new EndApplicationMessage();
|
|
|
|
|
+ endApplicationMessage.setEndApplicationMessageId(new BerObjectIdentifier(messageId));
|
|
|
|
|
+ endApplicationMessage.setEndApplicationMessageMsg(new BerAny(msgBuff.getArray()));
|
|
|
|
|
+
|
|
|
|
|
+ SubscriptionData subscriptionData = new SubscriptionData();
|
|
|
|
|
+ subscriptionData.setDatexSubscribePersistentBool(new BerBoolean(false));
|
|
|
|
|
+ subscriptionData.setDatexSubscribeStatusCd(new BerEnum(0)); // 0: New, 1: Update
|
|
|
|
|
+ subscriptionData.setDatexSubscribeMode(subscriptionMode);
|
|
|
|
|
+ subscriptionData.setDatexSubscribePublishFormatCd(new BerEnum(3)); // 0: other, 1: ftp, 2: tftp, 3: dataPacket
|
|
|
|
|
+ subscriptionData.setDatexSubscriptionPriorityNbr(new BerInteger(datexSubscriptionPriorityNbr));
|
|
|
|
|
+ subscriptionData.setDatexSubscribeGuaranteeBool(new BerBoolean(true));
|
|
|
|
|
+ subscriptionData.setDatexSubscribePdu(endApplicationMessage);
|
|
|
|
|
+
|
|
|
|
|
+ SubscriptionType subscriptionType = new SubscriptionType();
|
|
|
|
|
+ subscriptionType.setSubscription(subscriptionData);
|
|
|
|
|
+
|
|
|
|
|
+ Subscription subscription = new Subscription();
|
|
|
|
|
+ //subscription.setDatexSubscribeSerialNbr(new BerInteger(subscribeSerialNbr));
|
|
|
|
|
+ subscription.setDatexSubscribeSerialNbr(new BerInteger(subscribeSerialNbr));
|
|
|
|
|
+ subscription.setDatexSubscribeType(subscriptionType);
|
|
|
|
|
+
|
|
|
|
|
+ PDUs pdus = new PDUs();
|
|
|
|
|
+ pdus.setSubscription(subscription);
|
|
|
|
|
+ byte[] auth = { (byte) eAuthInfo.AI_Subscription.getValue() };
|
|
|
|
|
+ C2CAuthenticatedMessage c2c = new C2CAuthenticatedMessage();
|
|
|
|
|
+ c2c.setDatexAuthenticationInfoText(new BerOctetString(auth));
|
|
|
|
|
+ c2c.setDatexDataPacketNumber(new BerInteger(dataPacketNumber));
|
|
|
|
|
+ c2c.setDatexDataPacketPriorityNumber(new BerInteger(dataPacketPriorityNumber));
|
|
|
|
|
+ c2c.setOptions(new HeaderOptions());
|
|
|
|
|
+ c2c.setPdu(pdus);
|
|
|
|
|
+
|
|
|
|
|
+ ChannelFuture f = channel.writeAndFlush(c2c);
|
|
|
|
|
+ f.awaitUninterruptibly();
|
|
|
|
|
+ if (f.isDone() || f.isSuccess()) {
|
|
|
|
|
+ log.info("LoginDeviceService.requestObuGatherInfo: {}, {}, send ok", obj.getID(), obj.getRSE_ID());
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ log.error("LoginDeviceService.requestObuGatherInfo: {}, {}, send failed.", obj.getID(), obj.getRSE_ID());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e) {
|
|
|
|
|
+ log.error("LoginDeviceService.requestObuGatherInfo: {}, {}, Exception: {}", obj.getID(), obj.getRSE_ID(), e.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public boolean requestObuStatusInfo(TbRseCtlr obj, Channel channel) {
|
|
|
|
|
+
|
|
|
|
|
+ int updateDelayQty = 30;
|
|
|
|
|
+ String ipAddress = NettyUtils.getRemoteIpAddress(channel);
|
|
|
|
|
+ log.info("LoginDeviceService.requestObuStatusInfo: {}, {}, {}", obj.getID(), obj.getMcuID(), updateDelayQty);
|
|
|
|
|
+
|
|
|
|
|
+ int[] messageId = {1, 0, 15784, 4, 0, 7};
|
|
|
|
|
+ int dataPacketNumber = 2; //obj.getSeq().nextValue()
|
|
|
|
|
+ int dataPacketPriorityNumber = 0;
|
|
|
|
|
+ int datexSubscriptionPriorityNbr = 10;
|
|
|
|
|
+ int subscribeSerialNbr = 1;
|
|
|
|
|
+ try {
|
|
|
|
|
+ byte[] controlId = {3};
|
|
|
|
|
+ byte[] controlData = {};
|
|
|
|
|
+ ControlDevice controlDevice = new ControlDevice();
|
|
|
|
|
+ controlDevice.setVpbdControlID(new BerOctetString(controlId));
|
|
|
|
|
+ controlDevice.setVpbdControlDeviceData(new BerOctetString(controlData));
|
|
|
|
|
+ Registered registered = new Registered();
|
|
|
|
|
+ Registered.Continuous continuous = new Registered.Continuous();
|
|
|
|
|
+ SubscriptionMode subscriptionMode = new SubscriptionMode();
|
|
|
|
|
+
|
|
|
|
|
+ continuous.setDatexRegisteredUpdateDelayQty(new BerInteger(updateDelayQty));
|
|
|
|
|
+ continuous.setDatexRegisteredStartTime(DsrcAsn1Utils.getRegisterStartTime());
|
|
|
|
|
+ continuous.setDatexRegisteredEndTime(DsrcAsn1Utils.getRegisterEndTime());
|
|
|
|
|
+ registered.setContinuous(continuous);
|
|
|
|
|
+ subscriptionMode.setPeriodic(registered);
|
|
|
|
|
+
|
|
|
|
|
+ // ControlDeviceList set
|
|
|
|
|
+ ReverseByteArrayOutputStream msgBuff = new ReverseByteArrayOutputStream(1024);
|
|
|
|
|
+ ControlDeviceList controlDeviceList = new ControlDeviceList();
|
|
|
|
|
+ controlDeviceList.getControlDevice().add(controlDevice);
|
|
|
|
|
+ controlDeviceList.encode(msgBuff);
|
|
|
|
|
+
|
|
|
|
|
+ // EndApplicationMessage set
|
|
|
|
|
+ EndApplicationMessage endApplicationMessage = new EndApplicationMessage();
|
|
|
|
|
+ endApplicationMessage.setEndApplicationMessageId(new BerObjectIdentifier(messageId));
|
|
|
|
|
+ endApplicationMessage.setEndApplicationMessageMsg(new BerAny(msgBuff.getArray()));
|
|
|
|
|
+
|
|
|
|
|
+ SubscriptionData subscriptionData = new SubscriptionData();
|
|
|
|
|
+ subscriptionData.setDatexSubscribePersistentBool(new BerBoolean(false));
|
|
|
|
|
+ subscriptionData.setDatexSubscribeStatusCd(new BerEnum(0)); // 0: New, 1: Update
|
|
|
|
|
+ subscriptionData.setDatexSubscribeMode(subscriptionMode);
|
|
|
|
|
+ subscriptionData.setDatexSubscribePublishFormatCd(new BerEnum(3)); // 0: other, 1: ftp, 2: tftp, 3: dataPacket
|
|
|
|
|
+ subscriptionData.setDatexSubscriptionPriorityNbr(new BerInteger(datexSubscriptionPriorityNbr));
|
|
|
|
|
+ subscriptionData.setDatexSubscribeGuaranteeBool(new BerBoolean(true));
|
|
|
|
|
+ subscriptionData.setDatexSubscribePdu(endApplicationMessage);
|
|
|
|
|
+
|
|
|
|
|
+ SubscriptionType subscriptionType = new SubscriptionType();
|
|
|
|
|
+ subscriptionType.setSubscription(subscriptionData);
|
|
|
|
|
+
|
|
|
|
|
+ Subscription subscription = new Subscription();
|
|
|
|
|
+ subscription.setDatexSubscribeSerialNbr(new BerInteger(subscribeSerialNbr));
|
|
|
|
|
+ subscription.setDatexSubscribeType(subscriptionType);
|
|
|
|
|
+
|
|
|
|
|
+ PDUs pdus = new PDUs();
|
|
|
|
|
+ pdus.setSubscription(subscription);
|
|
|
|
|
+ byte[] auth = { (byte) eAuthInfo.AI_Subscription.getValue() };
|
|
|
|
|
+ C2CAuthenticatedMessage c2c = new C2CAuthenticatedMessage();
|
|
|
|
|
+ c2c.setDatexAuthenticationInfoText(new BerOctetString(auth));
|
|
|
|
|
+ c2c.setDatexDataPacketNumber(new BerInteger(dataPacketNumber));
|
|
|
|
|
+ c2c.setDatexDataPacketPriorityNumber(new BerInteger(dataPacketPriorityNumber));
|
|
|
|
|
+ c2c.setOptions(new HeaderOptions());
|
|
|
|
|
+ c2c.setPdu(pdus);
|
|
|
|
|
+
|
|
|
|
|
+ ChannelFuture f = channel.writeAndFlush(c2c);
|
|
|
|
|
+ f.awaitUninterruptibly();
|
|
|
|
|
+ if (f.isDone() || f.isSuccess()) {
|
|
|
|
|
+ log.info("LoginDeviceService.requestObuStatusInfo: {}, {}, {}, send ok", obj.getID(), obj.getMcuID(), updateDelayQty);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ log.error("LoginDeviceService.requestObuStatusInfo: {}, {}, {}, send failed.", obj.getID(), obj.getMcuID(), updateDelayQty);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e) {
|
|
|
|
|
+ log.error("LoginDeviceService.requestObuStatusInfo: {}, {}, {}, Exception: {}", obj.getID(), obj.getMcuID(), updateDelayQty, e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|