Skip to content

Commit

Permalink
MAB_runtime_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
j50ju committed Oct 10, 2024
1 parent 029afca commit 8b6facc
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 142 deletions.
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ dependencies {
implementation project(path: ':comp_spelling')

implementation project(path: ':comp_intervention')
implementation 'com.github.RoboTutorLLC:ScreenRecordHelper:1.0.0'
implementation ('com.github.RoboTutorLLC:ScreenRecordHelper:1.0.0') {
exclude group: 'com.blankj', module: 'utilcode'
}
implementation 'com.github.HBiSoft:HBRecorder:2.0.3'
}

Expand Down
37 changes: 35 additions & 2 deletions app/src/main/java/cmu/xprize/robotutor/RoboTutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
import java.util.Locale;
import java.util.Objects;

import java.util.Random;
import org.json.JSONArray;
import org.json.JSONObject;

import cmu.xprize.comp_intervention.data.CInterventionStudentData;
import cmu.xprize.comp_intervention.CInterventionTimes;
import cmu.xprize.comp_intervention.data.CUpdateInterventionStudentData;
Expand Down Expand Up @@ -207,6 +211,32 @@ public class RoboTutor extends Activity implements IReadyListener, IRoboTutor, H
ScreenRecordHelper screenRecordHelper;
private ScreenRecorder screenRecorder = null;

//Declare armName
private String armName = "default_arm";

public void setArmName() {
// Get the path to the arm-weights.json file
String armWeightsPath = TCONST.DOWNLOAD_PATH + "/arm-weights.json";
try {
String armWeightsData = JSON_Helper.cacheDataByName(armWeightsPath);
if (!armWeightsData.isEmpty()) {
JSONObject jsonObject = new JSONObject(armWeightsData);
JSONArray armsArray = jsonObject.getJSONArray("arms");

//(this part can be replaced by selecting arm by MABHandler later)
// Randomly select an arm from the armsArray
Random random = new Random();
int randomInd = random.nextInt(armsArray.length());
armName = armsArray.getJSONObject(randomInd).getString("name");

} else {
Log.e("LOG_DEBUG", "arm-weights.json is not found");
}
} catch (Exception e) {
Log.e("LOG_DEBUG", "Error loads the arm_weights.json: " + e.getMessage());
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {

Expand Down Expand Up @@ -249,7 +279,6 @@ protected void onCreate(Bundle savedInstanceState) {

VERSION_RT = BuildConfig.VERSION_NAME;
VERSION_SPEC = CAssetObject.parseVersionSpec(VERSION_RT);

initializeAndStartLogs();

//Log current config data
Expand Down Expand Up @@ -351,7 +380,7 @@ private void initializeAndStartLogs() {
String initTime = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss", Locale.US).format(calendar.getTime());
SEQUENCE_ID_STRING = String.format(Locale.US, "%06d", getNextLogSequenceId());
// NOTE: Need to include the configuration name when that is fully merged
String logFilename = "RoboTutor_" + // TODO TODO TODO there should be a version name in here!!!
String logFilename = "RoboTutor_" + armName + "_" + // TODO TODO TODO there should be a version name in here!!!
Configuration.configVersion(this) + "_" + BuildConfig.VERSION_NAME + "_" + SEQUENCE_ID_STRING +
"_" + initTime + "_" + Build.SERIAL;

Expand All @@ -373,6 +402,10 @@ private void initializeAndStartLogs() {
// TODO : implement time stamps
logManager.postDateTimeStamp(GRAPH_MSG, "RoboTutor:SessionStart");
logManager.postEvent_I(GRAPH_MSG, "EngineVersion:" + VERSION_RT);
// Set the armName and rename the log file after it is picked
setArmName();
logFilename = logFilename.replace("default_arm", armName);
Log.w("LOG_DEBUG", "Log filename updated: " +logFilename);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion comp_nd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ dependencies {
api project (':resources')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'com.google.android:flexbox:1.0.0'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
}
10 changes: 9 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
# Default value: -Xmx10248m -XX:MaxPermSize=256m
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3072m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx3072m \
--add-opens java.base/java.io=ALL-UNNAMED \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.lang.invoke=ALL-UNNAMED \
--add-opens java.base/java.nio.charset=ALL-UNNAMED \
--add-opens java.base/java.net=ALL-UNNAMED \
--add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED


# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Jan 02 13:34:20 IST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
a
Loading

0 comments on commit 8b6facc

Please sign in to comment.