com.envision.energy.App Maven / Gradle / Ivy
package com.envision.energy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.envision.energy.eos.exception.EOSClientException;
import com.envision.energy.eos.sdk.*;
import com.envision.energy.sdk.eos.calculate.data.PointCal;
import com.envision.energy.sdk.eos.core.Alarm;
import com.envision.energy.sdk.eos.core.Point;
import com.envision.eos.event.api.bo.Event;
import com.google.common.base.Strings;
/**
* Hello world!
*/
public class App {
public static void main(String[] args) throws InterruptedException, EOSClientException {
String appKey = "xxxxxxxxxxxx";
String appSecrect = "xxxxxxxxxxxxxxxxx";
String url = "127.0.0.1:9001";
IDataHandler handler1 = new IDataHandler() {
@Override
public void dataRead(Point point) {
System.out.println("1 :::: " + point);
}
};
IDataHandler handler2 = new IDataHandler() {
@Override
public void dataRead(Point point) {
System.out.println("2 :::: " + point);
}
};
EOSClient eosCli = new EOSClient(appKey, appSecrect, url);
IDataService dataService = eosCli.getDataService();
IEventService eventService = eosCli.getEventService();
IEventHandler eventHandler1 = new IEventHandler() {
@Override
public void eventRead(Event event) {
if (event == null) {
System.out.println("event is null...");
}
System.out.println("event customer : " + event.getSiteId() + " " + event.getCode() + " " + event.getInfo());
}
};
IEventHandler eventHandler2 = new IEventHandler(){
@Override
public void eventRead(Event event) {
if (event == null) {
System.out.println("event is null...");
}
System.out.println("event site & code : " + event.getSiteId() + " " + event.getCode() + " " + event.getInfo());
}
};
try
{
// dataService.subscribe(new IDataHandler() {
//
// @Override
// public void dataRead(Point point) {
// System.out.println("get point: " + point);
//
// }
// });
// List points = new ArrayList<>();
// points.add("point1");
// points.add("point2");
// points.add("point3");
// points.add("point4");
// points.add("point5");
// //@1
// dataService.subscribe(handler1, points);
//
// List pointInfo = new ArrayList<>();
// PointInfo point = new PointInfo();
// point.setDeviceId("deviceID");
// point.setPointId("point6");
// pointInfo.add(point);
//
// dataService.subscribe(handler2, points);
//@2
// dataService.subscribe(new IPointCalHandler() {
//
// @Override
// public void pointRead(PointCal point) {
// System.out.println("3 :::: " + point);
// }
// }, points);
//
// alarmService.subscribe(new IAlarmHandler() {
//
// @Override
// public void alarmRead(Alarm alarm) {
// System.out.println("get alarm: " + alarm);
//
// }
// });
List customerIDs = new ArrayList<>();
customerIDs.add("customerID");
eventService.subscribe(eventHandler1, customerIDs);
List siteIDs = new ArrayList<>();
siteIDs.add("siteId1");
siteIDs.add("siteId2");
siteIDs.add("siteId3");
List codeIDS = new ArrayList<>();
codeIDS.add("codeID");
eventService.subscribe(eventHandler2, siteIDs, codeIDS);
} catch (
Exception e
)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
int i = 0;
while (true)
{
Thread.sleep(1000);
}
}
}