本文整理汇总了Java中org.md2k.datakitapi.exception.DataKitException类的典型用法代码示例。如果您正苦于以下问题:Java DataKitException类的具体用法?Java DataKitException怎么用?Java DataKitException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataKitException类属于org.md2k.datakitapi.exception包,在下文中一共展示了DataKitException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public void subscribe(String platformType, final String dataSourceType) throws DataKitException {
DataSourceClient dataSourceClient = findDataSourceClient(platformType, dataSourceType);
dataKitAPI.subscribe(dataSourceClient, new OnReceiveListener() {
@Override
public void onReceived(DataType dataType) {
try {
DataTypeDoubleArray dataTypeDoubleArray = (DataTypeDoubleArray) dataType;
CSVDataPoint csvDataPoint = new CSVDataPoint(dataSourceTypeTOChannel.get(dataSourceType), dataTypeDoubleArray.getDateTime(), dataTypeDoubleArray.getSample()[0]);
streamProcessorWrapper.addDataPoint(csvDataPoint);
} catch (Exception ignored) {
}
}
});
}
示例2: findDataSourceClient
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
protected DataSourceClient findDataSourceClient(String platformType, String platformId, String dataSourceType) {
PlatformBuilder platformBuilder = new PlatformBuilder().setType(platformType).setId(platformId);
DataSourceBuilder dataSourceBuilder = new DataSourceBuilder();
if (dataSourceType != null && dataSourceType.length() != 1)
dataSourceBuilder.setType(dataSourceType);
dataSourceBuilder.setPlatform(platformBuilder.build());
ArrayList<DataSourceClient> dataSourceClientArrayList = null;
try {
dataSourceClientArrayList = dataKitAPI.find(dataSourceBuilder);
} catch (DataKitException e) {
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.INTENT_STOP));
return null;
}
if (dataSourceClientArrayList.size() != 1)
return null;
return dataSourceClientArrayList.get(0);
}
示例3: run
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
@Override
public void run() {
Application application = new ApplicationBuilder().setId("org.md2k.notificationmanager").build();
DataSourceBuilder dataSourceBuilder = new DataSourceBuilder().setType(DataSourceType.NOTIFICATION_REQUEST).setApplication(application);
try {
dataSourceClietNotificationRequests = DataKitAPI.getInstance(context).find(dataSourceBuilder);
Log.d(TAG, "datasourceclient=" + dataSourceClietNotificationRequests.size());
if (dataSourceClietNotificationRequests.size() == 0) {
if (RERUN > 0) {
RERUN--;
handler.postDelayed(this, 1000);
} else handler.postDelayed(this, 60000);
} else {
subscribe();
}
} catch (DataKitException e) {
Intent intent = new Intent(Constants.INTENT_STOP);
intent.putExtra("type", "NotificationManager.java...runnableSubscribe()");
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
}
示例4: register
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public PendingResult<DataSourceClient> register(final DataSourceBuilder dataSourceBuilder) throws DataKitException {
PendingResult<DataSourceClient> pendingResult = new PendingResult<DataSourceClient>() {
@Override
public DataSourceClient await() {
try {
registerData = null;
lock();
DataSource dataSource = prepareDataSource(dataSourceBuilder);
Bundle bundle = new Bundle();
bundle.putParcelable(DataSource.class.getSimpleName(), dataSource);
prepareAndSend(bundle, MessageType.REGISTER);
semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
} catch (Exception e) {
registerData = null;
} finally {
unlock();
}
return registerData;
}
};
return pendingResult;
}
示例5: unregister
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public PendingResult<Status> unregister(final DataSourceClient dataSourceClient) throws DataKitException {
PendingResult<Status> pendingResult = new PendingResult<Status>() {
@Override
public Status await() {
try {
unregisterData = null;
lock();
Bundle bundle = new Bundle();
bundle.putInt(Constants.RC_DSID, dataSourceClient.getDs_id());
prepareAndSend(bundle, MessageType.UNREGISTER);
semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
} catch (Exception e) {
unregisterData = null;
} finally {
unlock();
}
return unregisterData;
}
};
return pendingResult;
}
示例6: subscribe
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public Status subscribe(final DataSourceClient dataSourceClient, OnReceiveListener onReceiveListener) throws DataKitException {
try {
subscribeData = null;
lock();
ds_idOnReceiveListenerHashMap.put(dataSourceClient.getDs_id(), onReceiveListener);
Bundle bundle = new Bundle();
bundle.putInt(Constants.RC_DSID, dataSourceClient.getDs_id());
bundle.putString(Constants.PACKAGE_NAME, context.getPackageName());
prepareAndSend(bundle, MessageType.SUBSCRIBE);
semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
} catch (Exception e) {
Log.e(TAG, "Subscribe error..." + dataSourceClient.getDs_id());
subscribeData = null;
} finally {
unlock();
}
return subscribeData;
}
示例7: find
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public PendingResult<ArrayList<DataSourceClient>> find(final DataSourceBuilder dataSourceBuilder) throws DataKitException {
PendingResult<ArrayList<DataSourceClient>> pendingResult = new PendingResult<ArrayList<DataSourceClient>>() {
@Override
public ArrayList<DataSourceClient> await() {
try {
findData = null;
lock();
final DataSource dataSource = dataSourceBuilder.build();
Bundle bundle = new Bundle();
bundle.putParcelable(DataSource.class.getSimpleName(), dataSource);
prepareAndSend(bundle, MessageType.FIND);
semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
} catch (Exception e) {
findData = null;
} finally {
unlock();
}
return findData;
}
};
return pendingResult;
}
示例8: query
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public PendingResult<ArrayList<DataType>> query(final DataSourceClient dataSourceClient, final long starttimestamp, final long endtimestamp) throws DataKitException {
return new PendingResult<ArrayList<DataType>>() {
@Override
public ArrayList<DataType> await() {
try {
queryData = null;
lock();
Bundle bundle = new Bundle();
bundle.putInt(Constants.RC_DSID, dataSourceClient.getDs_id());
bundle.putLong(Constants.RC_STARTTIMESTAMP, starttimestamp);
bundle.putLong(Constants.RC_ENDTIMESTAMP, endtimestamp);
prepareAndSend(bundle, MessageType.QUERY);
semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
} catch (Exception e) {
queryData = null;
} finally {
unlock();
}
return queryData;
}
};
}
示例9: queryFromPrimaryKey
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public PendingResult<ArrayList<RowObject>> queryFromPrimaryKey(final DataSourceClient dataSourceClient, final long lastSyncedValue, final int limit) throws DataKitException {
return new PendingResult<ArrayList<RowObject>>() {
@Override
public ArrayList<RowObject> await() {
try {
queryPrimaryKeyData = null;
lock();
Bundle bundle = new Bundle();
bundle.putInt(Constants.RC_DSID, dataSourceClient.getDs_id());
bundle.putLong(Constants.RC_LAST_KEY, lastSyncedValue);
bundle.putInt(Constants.RC_LIMIT, limit);
prepareAndSend(bundle, MessageType.QUERYPRIMARYKEY);
semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
} catch (Exception e) {
queryPrimaryKeyData = null;
} finally {
unlock();
}
return queryPrimaryKeyData;
}
};
}
示例10: querySize
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public PendingResult<DataTypeLong> querySize() throws DataKitException {
return new PendingResult<DataTypeLong>() {
@Override
public DataTypeLong await() {
try {
querySizeData = null;
lock();
Bundle bundle = new Bundle();
prepareAndSend(bundle, MessageType.QUERYSIZE);
semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
} catch (Exception e) {
querySizeData = null;
} finally {
unlock();
}
return querySizeData;
}
};
}
示例11: onSensorChanged
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
@Override
public void onSensorChanged(SensorEvent event) {
long curTime = DateTime.getDateTime();
if ((double)(curTime - lastSaved) > FILTER_DATA_MIN_TIME) {
lastSaved = curTime;
double[] samples = new double[3];
samples[DataFormat.Gyroscope.X] = event.values[0];
samples[DataFormat.Gyroscope.Y] = event.values[1];
samples[DataFormat.Gyroscope.Z] = event.values[2];
DataTypeDoubleArray dataTypeDoubleArray = new DataTypeDoubleArray(curTime, samples);
try {
dataKitAPI.insertHighFrequency(dataSourceClient, dataTypeDoubleArray);
callBack.onReceivedData(dataTypeDoubleArray);
} catch (DataKitException e) {
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ServicePhoneSensor.INTENT_STOP));
}
}
}
示例12: saveData
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public void saveData(Location location) {
double samples[] = new double[6];
samples[DataFormat.Location.Latitude] = location.getLatitude();
samples[DataFormat.Location.Longitude] = location.getLongitude();
samples[DataFormat.Location.Altitude] = location.getAltitude();
samples[DataFormat.Location.Speed] = location.getSpeed();
samples[DataFormat.Location.Bearing] = location.getBearing();
samples[DataFormat.Location.Accuracy] = location.getAccuracy();
DataTypeDoubleArray dataTypeDoubleArray = new DataTypeDoubleArray(DateTime.getDateTime(), samples);
try {
dataKitAPI.insert(dataSourceClient, dataTypeDoubleArray);
callBack.onReceivedData(dataTypeDoubleArray);
} catch (DataKitException e) {
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ServicePhoneSensor.INTENT_STOP));
}
}
示例13: register
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
@Override
public void register(DataSourceBuilder dataSourceBuilder, CallBack newCallBack) throws DataKitException {
super.register(dataSourceBuilder, newCallBack);
context.registerReceiver(br, new IntentFilter("android.location.PROVIDERS_CHANGED"));
prepareObservable();
updatableLocationSubscription = locationUpdatesObservable.subscribe(new Observer<Location>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Location location) {
saveData(location);
}
});
}
示例14: onSensorChanged
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
@Override
public void onSensorChanged(SensorEvent event) {
long curTime = DateTime.getDateTime();
if ((double)(curTime - lastSaved) > FILTER_DATA_MIN_TIME) {
lastSaved = curTime;
double[] samples = new double[3];
samples[DataFormat.Accelerometer.X] = event.values[0]/9.81;
samples[DataFormat.Accelerometer.Y] = event.values[1]/9.81;
samples[DataFormat.Accelerometer.Z] = event.values[2]/9.81;
DataTypeDoubleArray dataTypeDoubleArray = new DataTypeDoubleArray(curTime, samples);
try {
dataKitAPI.insertHighFrequency(dataSourceClient, dataTypeDoubleArray);
callBack.onReceivedData(dataTypeDoubleArray);
} catch (DataKitException e) {
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ServicePhoneSensor.INTENT_STOP));
}
}
}
示例15: register
import org.md2k.datakitapi.exception.DataKitException; //导入依赖的package包/类
public void register(DataSourceBuilder dataSourceBuilder, CallBack newCallBack) throws DataKitException {
super.register(dataSourceBuilder, newCallBack);
mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
switch (frequency) {
case SENSOR_DELAY_UI:
FILTER_DATA_MIN_TIME = 1000.0 / (16.0 + EPSILON_UI);
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_UI);
break;
case SENSOR_DELAY_GAME:
FILTER_DATA_MIN_TIME = 1000.0 / (50.0 + EPSILON_GAME);
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_GAME);
break;
case SENSOR_DELAY_FASTEST:
FILTER_DATA_MIN_TIME = 1000.0 / (100.0 + EPSILON_FASTEST);
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_FASTEST);
break;
case SENSOR_DELAY_NORMAL:
FILTER_DATA_MIN_TIME = 1000.0 / (6.0 + EPSILON_NORMAL);
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
break;
}
}