本文整理汇总了Java中edu.mit.media.funf.time.TimeUtil类的典型用法代码示例。如果您正苦于以下问题:Java TimeUtil类的具体用法?Java TimeUtil怎么用?Java TimeUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeUtil类属于edu.mit.media.funf.time包,在下文中一共展示了TimeUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSensorChanged
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
public void onSensorChanged(SensorEvent event) {
JsonObject sensingData = new JsonObject();
sensingData.addProperty(TIMESTAMP,
TimeUtil.uptimeNanosToTimestamp(event.timestamp));
sensingData.addProperty(ACCURACY, event.accuracy);
final String[] valueNames = getValueNames();
int valuesLength = Math.min(event.values.length, valueNames.length);
for (int i = 0; i < valuesLength; i++) {
String valueName = valueNames[i];
sensingData.addProperty(valueName, event.values[i]);
}
sendData(sensingData);
}
开发者ID:chauhansaurabhb,项目名称:EndUserInteractioion_RequestResponse_Command,代码行数:21,代码来源:LightSensorProbe.java
示例2: onDataReceived
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
public void onDataReceived(IJsonObject completeProbeUri, IJsonObject data) {
Log.d(LogUtil.TAG, "SimpleLocationProbe received data: " + data.toString());
if (startTime == null) {
startTime = TimeUtil.getTimestamp();
getHandler().postDelayed(sendLocationRunnable, TimeUtil.secondsToMillis(maxWaitTime));
}
if (isBetterThanCurrent(data)) {
Log.d(LogUtil.TAG, "SimpleLocationProbe evaluated better location.");
bestLocation = data;
}
if (goodEnoughAccuracy != null && bestLocation.get(ACCURACY).getAsDouble() < goodEnoughAccuracy.doubleValue()) {
Log.d(LogUtil.TAG, "SimpleLocationProbe evaluated good enough location.");
if (getState() == State.RUNNING) { // Actively Running
stop();
} else if (getState() == State.ENABLED) { // Passive listening
// TODO: do we want to prematurely end this, or wait for the full duration
// Things to consider:
// - the device falling to sleep before we send
// - too much unrequested data if we send all values within accuracy limits
// (this will restart immediately if more passive data continues to come in)
getHandler().removeCallbacks(sendLocationRunnable);
sendCurrentBestLocation();
}
}
}
示例3: onEnable
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
protected void onEnable() {
super.onEnable();
sensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(getSensorType());
final String[] valueNames = getValueNames();
sensorListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
JsonObject data = new JsonObject();
data.addProperty(TIMESTAMP, TimeUtil.uptimeNanosToTimestamp(event.timestamp));
data.addProperty(ACCURACY, event.accuracy);
int valuesLength = Math.min(event.values.length, valueNames.length);
for (int i = 0; i < valuesLength; i++) {
String valueName = valueNames[i];
data.addProperty(valueName, event.values[i]);
}
sendData(data);
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
};
}
示例4: onStart
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
Log.d(LogUtil.TAG, "SimpleLocationProbe starting, registering listener");
startTime = TimeUtil.getTimestamp();
locationProbe.registerListener(listener);
getHandler().sendMessageDelayed(getHandler().obtainMessage(STOP_MESSAGE), TimeUtil.secondsToMillis(maxWaitTime));
}
示例5: onStart
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
startDiscovery();
if (maxScanTime != null) {
getHandler().sendMessageDelayed(getHandler().obtainMessage(STOP_MESSAGE), TimeUtil.secondsToMillis(maxScanTime));
}
}
示例6: run
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
public void run() {
if (am != null) {
List<RecentTaskInfo> currentTasks = am.getRecentTasks(1, ActivityManager.RECENT_WITH_EXCLUDED);
if (!currentTasks.isEmpty()) {
RecentTaskInfo updatedTask = currentTasks.get(0);
if (currentRunningTask == null || !currentRunningTask.baseIntent.filterEquals(updatedTask.baseIntent)) {
endCurrentTask();
currentRunningTask = updatedTask;
currentRunningTaskStartTime = TimeUtil.getTimestamp();
}
}
getHandler().postDelayed(this, TimeUtil.secondsToMillis(pollInterval));
}
}
示例7: endCurrentTask
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
public void endCurrentTask() {
if (currentRunningTask != null && currentRunningTaskStartTime != null) {
BigDecimal duration = TimeUtil.getTimestamp().subtract(currentRunningTaskStartTime);
sendData(currentRunningTask, currentRunningTaskStartTime, duration);
reset();
}
}
示例8: getNextTime
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
public BigDecimal getNextTime(Number previousTime) {
if (interval == null) {
return null;
} else if (previousTime == null) {
return TimeUtil.getTimestamp();
} else {
return DecimalTimeUnit.decimal(previousTime).add(interval);
}
}
示例9: set
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
public void set(String type, Uri componentAndAction, Schedule schedule) {
// Creates pending intents that will call back into FunfManager
// Uses alarm manager to time them
Intent intent = getFunfIntent(context, type, componentAndAction);
PendingIntent operation = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// TODO: figure out how to do previous time for all components, including pipeline actions
Number previousTime = null;
// TODO: add random start for initial
// startTimeMillis += random;
BigDecimal startTime = schedule.getNextTime(previousTime);
if (startTime != null) {
long startTimeMillis = TimeUtil.secondsToMillis(startTime);
if (schedule.getInterval() == null || schedule.getInterval().intValue() == 0) {
alarmManager.set(AlarmManager.RTC_WAKEUP, startTimeMillis, operation);
} else {
long intervalMillis = TimeUtil.secondsToMillis(schedule.getInterval());
if (schedule.isStrict()) {
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, startTimeMillis, intervalMillis, operation);
} else {
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, startTimeMillis, intervalMillis, operation);
}
}
}
}
示例10: onCreate
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATA_TABLE.getCreateTableSQL());
db.execSQL(FILE_INFO_TABLE.getCreateTableSQL());
// Insert file identifier information
String installationUuid = UuidUtil.getInstallationId(context);
String fileUuid = UUID.randomUUID().toString();
double createdTime = TimeUtil.getTimestamp().doubleValue();
db.execSQL(String.format(Locale.US, "insert into %s (%s, %s, %s, %s) values ('%s', '%s', '%s', %f)",
FILE_INFO_TABLE.name,
COLUMN_DATABASE_NAME, COLUMN_INSTALLATION, COLUMN_UUID, COLUMN_CREATED,
databaseName, installationUuid, fileUuid, createdTime));
}
示例11: generateName
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
public String generateName(final String name) {
return name == null ? null : TimeUtil.getTimestamp() + "_" + name;
}
开发者ID:chauhansaurabhb,项目名称:EndUserInteractioion_RequestResponse_Command,代码行数:5,代码来源:NameGenerator.java
示例12: onDataReceived
import edu.mit.media.funf.time.TimeUtil; //导入依赖的package包/类
@Override
public void onDataReceived(IJsonObject completeProbeUri, IJsonObject acclerometerData) {
double currentSecs = acclerometerData.get(AccelerometerSensorProbe.TIMESTAMP).getAsDouble();
double x = acclerometerData.get(AccelerometerSensorProbe.X).getAsDouble();
double y = acclerometerData.get(AccelerometerSensorProbe.Y).getAsDouble();
double z = acclerometerData.get(AccelerometerSensorProbe.Z).getAsDouble();
if (prevSecs == 0)
{
prevSecs = currentSecs;
}
double diffSecs = currentSecs - prevSecs;
prevSecs = currentSecs;
frameBuffer[frameSamples][0] = x;
frameBuffer[frameSamples][1] = y;
frameBuffer[frameSamples][2] = z;
frameSamples ++;
frameTimer += diffSecs;
if ((frameTimer >= frameDuration) || (frameSamples == (frameBufferSize - 1))) {
JsonObject data = new JsonObject();
double fN = (double)frameSamples;
if (prevFrameSecs == 0) {
prevFrameSecs = currentSecs;
}
double diffFrameSecs = currentSecs - prevFrameSecs;
prevFrameSecs = currentSecs;
data.addProperty(TIMESTAMP, currentSecs);
data.addProperty(DIFF_FRAME_SECS, new BigDecimal(diffFrameSecs).setScale(TimeUtil.MICRO, RoundingMode.HALF_EVEN));
data.addProperty(NUM_FRAME_SAMPLES, frameSamples);
data.add(X, getFeatures(0, fN));
data.add(Y, getFeatures(1, fN));
data.add(Z, getFeatures(2, fN));
sendData(data);
// Reset frame buffer counters
frameSamples = 0;
frameTimer = 0;
// Ensure buffer is zero-padded
for (double[] row: frameBuffer) {
Arrays.fill(row, 0);
}
}
}