0
當我在樹莓派PI上啓動KAA客戶機SDK(JAVA)時,CPU使用率高達100%。只要我殺的過程中CPU佔用率降回正常在kaa客戶機上啓動PI時CPU佔用率高
下面是一個使用的地方開始我開始了KAA客戶端上的樹莓派
public class NotificationSystemTestApp {
private static final Logger LOG = LoggerFactory.getLogger(NotificationSystemTestApp.class);
public static void main(String[] args) throws InterruptedException {
/*System.out.println(encryptString("abcd", "12332sd1133sdssd45"));
return;*/
new NotificationSystemTestApp().launch();
}
private void launch() throws InterruptedException {
// Create client for Kaa SDK
final KaaClient kaaClient;
DesktopKaaPlatformContext desktopKaaPlatformContext = new DesktopKaaPlatformContext();
final CountDownLatch startupLatch = new CountDownLatch(1);
kaaClient = Kaa.newClient(desktopKaaPlatformContext, new SimpleKaaClientStateListener() {
@Override
public void onStarted() {
LOG.info("--= Kaa client started =--");
startupLatch.countDown();
}
@Override
public void onStopped() {
LOG.info("--= Kaa client stopped =--");
}
}, true);
kaaClient.setProfileContainer(new ProfileContainer() {
public ClientProfile getProfile() {
return new ClientProfile() {{
setClientProfileInfo(new ProfileInfo() {{
setRidlrId("R_00001");
setStationName("Mumbai");
setEquipmentId("EQ0006");
setStationId("5");
}});
}};
}
});
// Registering listener for topic updates
kaaClient.start();
startupLatch.await();
kaaClient.addTopicListListener(new NotificationTopicListListener() {
public void onListUpdated(List<Topic> topicList) {
System.out.println("Topic list updated!");
for (Topic topic : topicList) {
LOG.info("Received topic with id {} and name {}", topic.getId(), topic.getName());
}
}
});
final ScanInfo scanInfo = new ScanInfo() {{
setDestinationId("12");
setSourceId("3");
setEquipmentId("R_00001");
setScanTime(System.currentTimeMillis()/1000);
setEvent("ENTRY");
setTransactionId(UUID.randomUUID().toString());
}};
kaaClient.attachEndpoint(new EndpointAccessToken("1234"), new OnAttachEndpointOperationCallback() {
@Override
public void onAttach(SyncResponseResultType result, EndpointKeyHash resultContext) {
}
});
kaaClient.attachUser("user1", "1234", new UserAttachCallback() {
public void onAttachResult(UserAttachResponse response) {
System.out.println("Attach User Success - " + response.getResult());
}
});
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
LOG.error("FATA", e);
}
LOG.debug("End Point key hash - " + kaaClient.getEndpointKeyHash());
while (true) {
kaaClient.addLogRecord(new LoggerSchema() {{
setData("");
setMessageType("");
}});
Thread.sleep(10);
}
}
}
感謝, RIZWAN的KAA的代碼片段