Skip to content

Commit

Permalink
Fixed log write
Browse files Browse the repository at this point in the history
  • Loading branch information
mmlevin committed Oct 2, 2015
1 parent 014e905 commit 152050f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
4 changes: 0 additions & 4 deletions secu3droid/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
</ScrollView>

<LinearLayout
style="?android:attr/buttonBarStyle"
android:id="@+id/mainLogButtonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -89,21 +88,18 @@
android:layout_above="@id/mainTextFWInfo">

<Button
style="?android:attr/buttonBarButtonStyle"
android:id="@+id/mainLogButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/log_marker_1" />

<Button
style="?android:attr/buttonBarButtonStyle"
android:id="@+id/mainLogButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/log_marker_2" />

<Button
style="?android:attr/buttonBarButtonStyle"
android:id="@+id/mainLogButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
13 changes: 6 additions & 7 deletions secu3droid/src/org/secu3/android/ParamActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,14 @@ protected void onCreate(Bundle savedInstanceState) {
Skeletons = new SparseArray<>();
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
uploadImmediatelly = sharedPref.getBoolean(getString(R.string.pref_upload_immediately_key), false);
setTheme(sharedPref.getBoolean(getString(R.string.pref_night_mode_key), false)?R.style.AppBaseTheme:R.style.AppBaseTheme_Light);
setTheme(sharedPref.getBoolean(getString(R.string.pref_night_mode_key), false) ? R.style.AppBaseTheme : R.style.AppBaseTheme_Light);
setContentView(R.layout.activity_param);

createFormFromXml(R.xml.parameters, SettingsActivity.getProtocolVersion(this));

packetUtils = new PacketUtils(this);
paramAdapter = new ParamPagerAdapter(getSupportFragmentManager(),this,pages);
progressBar = (ProgressBar)findViewById(R.id.paramsProgressBar);
//FIXME Move to onResume or do after receive last skeleton
paramsRead();

receiver = new ReceiveMessages();
textViewStatus = (TextView) findViewById(R.id.paramsTextViewStatus);
Expand Down Expand Up @@ -435,7 +433,8 @@ protected void onPause() {

@Override
protected void onResume() {
super.onResume();
super.onResume();
registerReceiver(receiver, receiver.intentFilter);
startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON, Uri.EMPTY, this, Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.starter_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.angles_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.idling_title));
Expand All @@ -446,7 +445,7 @@ protected void onResume() {
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.ckps_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.knock_par_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.miscellaneous_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.choke_control_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON, Uri.EMPTY, this, Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.choke_control_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.secur_par_title).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_DIR, Secu3Packet.OUTPUT_TYPE));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.uniout_par_title));
startService(new Intent (Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON,Uri.EMPTY,this,Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM, R.string.injctr_par_title));
Expand All @@ -456,8 +455,8 @@ protected void onResume() {
dialog = (CustomNumberPickerDialog)getLastCustomNonConfigurationInstance();
if (dialog != null) {
dialog.setOnCustomNumberPickerAcceptListener(this);
}
registerReceiver(receiver, receiver.intentFilter);
}
paramsRead();
}


Expand Down
7 changes: 6 additions & 1 deletion secu3droid/src/org/secu3/android/api/io/Secu3Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void updateProgress(int progress) {

void updateTask() {
if (!tasks.isEmpty()) {
//prevSecu3Task = SECU3_TASK.SECU3_NONE;
prevSecu3Task = SECU3_TASK.SECU3_NONE;
secu3Task = tasks.poll();
}
}
Expand Down Expand Up @@ -477,6 +477,11 @@ void parsePacket(String packet, BufferedReader reader,
updateProgress(17 + subprogress);
updateTask();
break;
default:
tasks.add(SECU3_TASK.SECU3_READ_PARAMS);
subprogress = 0;
updateTask();
break;
}
break;
case SECU3_READ_ERRORS:
Expand Down
40 changes: 30 additions & 10 deletions secu3droid/src/org/secu3/android/api/io/Secu3SensorLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Secu3SensorLogger extends Secu3Logger {
private PacketUtils packetUtils = null;

private static char CSV_DELIMETER = ';';
private static final String cCSVTimeTemplateString = "%02d:02%02d.%02d";
private static final String cCSVTimeTemplateString = "%02d:%02d:%02d.%02d";
private static final String cCSVFileNameTemplateString = "%04d.%02d.%02d_%02d.%02d.%02d.csv";

private int marker = 0;
Expand Down Expand Up @@ -91,16 +91,36 @@ private String logString (Secu3Packet packet) {
out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_air_temperature_title)).getValue(), CSV_DELIMETER);
}
else {
out += String.format(Locale.US, "%6.2f%c", 0.0, CSV_DELIMETER);
out += String.format(Locale.US, "%6.2f%c", 999.99, CSV_DELIMETER);
}

out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_start_map_title)).getValue(), CSV_DELIMETER);
out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_idle_map_title)).getValue(), CSV_DELIMETER);
out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_work_map_title)).getValue(), CSV_DELIMETER);
out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_cool_temp_map_title)).getValue(), CSV_DELIMETER);
out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_air_temp_map_title)).getValue(), CSV_DELIMETER);
out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_idling_regulator_title)).getValue(), CSV_DELIMETER);
out += String.format(Locale.US, "%6.2f%c", ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_octane_correction_title)).getValue(), CSV_DELIMETER);
int temp = ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_start_map_title)).getIntValue();
float val = (temp == 0x7FFF)?0.00f:((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_start_map_title)).getValue();
out += String.format(Locale.US, "%6.2f%c", val, CSV_DELIMETER);

temp = ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_idle_map_title)).getIntValue();
val = (temp == 0x7FFF)?0.00f:((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_idle_map_title)).getValue();
out += String.format(Locale.US, "%6.2f%c", val, CSV_DELIMETER);

temp = ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_work_map_title)).getIntValue();
val = (temp == 0x7FFF)?0.00f:((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_work_map_title)).getValue();
out += String.format(Locale.US, "%6.2f%c", val, CSV_DELIMETER);

temp = ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_cool_temp_map_title)).getIntValue();
val = (temp == 0x7FFF)?0.00f:((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_angle_cool_temp_map_title)).getValue();
out += String.format(Locale.US, "%6.2f%c", val, CSV_DELIMETER);

temp = ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_air_temp_map_title)).getIntValue();
val = (temp == 0x7FFF)?0.00f:((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_air_temp_map_title)).getValue();
out += String.format(Locale.US, "%6.2f%c", val, CSV_DELIMETER);

temp = ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_idling_regulator_title)).getIntValue();
val = (temp == 0x7FFF)?0.00f:((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_idling_regulator_title)).getValue();
out += String.format(Locale.US, "%6.2f%c", val, CSV_DELIMETER);

temp = ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_octane_correction_title)).getIntValue();
val = (temp == 0x7FFF)?0.00f:((ProtoFieldFloat) packet.getField(R.string.sensor_dat_advance_octane_correction_title)).getValue();
out += String.format(Locale.US, "%6.2f%c", val, CSV_DELIMETER);
}

if (protocol_version >= SettingsActivity.PROTOCOL_10022015_WINTER_RELEASE) {
Expand Down Expand Up @@ -140,7 +160,7 @@ public void setMarker (int marker) {
@Override
public String getFileName() {
getTime().setTime(new Date());
return String.format(Locale.US, cCSVFileNameTemplateString, getTime().get(Calendar.YEAR), getTime().get(Calendar.MONTH),getTime().get(Calendar.DAY_OF_MONTH),getTime().get(Calendar.HOUR_OF_DAY),getTime().get(Calendar.MINUTE),getTime().get(Calendar.SECOND));
return String.format(Locale.US, cCSVFileNameTemplateString, getTime().get(Calendar.YEAR), getTime().get(Calendar.MONTH)+1,getTime().get(Calendar.DAY_OF_MONTH),getTime().get(Calendar.HOUR_OF_DAY),getTime().get(Calendar.MINUTE),getTime().get(Calendar.SECOND));
}

public void setCsvDelimeter (String delimeter) {
Expand Down

0 comments on commit 152050f

Please sign in to comment.