Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/java/io/pslab/activity/DataLoggerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.pslab.models.BaroData;
import io.pslab.models.CompassData;
import io.pslab.models.GyroData;
import io.pslab.models.LogicAnalyzerData;
import io.pslab.models.LuxData;
import io.pslab.models.OscilloscopeData;
import io.pslab.models.PowerSourceData;
Expand Down Expand Up @@ -120,6 +121,9 @@ protected void onCreate(Bundle savedInstanceState) {
case "Power Source":
categoryData = LocalDataLog.with().getTypeOfSensorBlocks(getResources().getString(R.string.power_source));
break;
case "Logic Analyzer":
categoryData = LocalDataLog.with().getTypeOfSensorBlocks(getResources().getString(R.string.logical_analyzer));
break;
default:
categoryData = LocalDataLog.with().getAllSensorBlocks();
getSupportActionBar().setTitle(getString(R.string.logged_data));
Expand Down Expand Up @@ -279,6 +283,9 @@ private RealmObject getObject(String objectType, String[] data, long time, long
case "Power Source":
returnObject = new PowerSourceData(time, block, Float.valueOf(data[2]), Float.valueOf(data[3]), Float.valueOf(data[4]), Float.valueOf(data[5]), Float.valueOf(data[6]), Float.valueOf(data[7]));
break;
case "Logic Analyzer":
returnObject = new LogicAnalyzerData(time, block, data[2], Integer.valueOf(data[3]), data[4], data[5], Float.valueOf(data[6]), Float.valueOf(data[7]));
break;
default:
returnObject = null;
break;
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/java/io/pslab/activity/LogicalAnalyzerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.support.design.widget.BottomSheetBehavior;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.TooltipCompat;
import android.view.GestureDetector;
import android.view.MenuItem;
import android.view.MotionEvent;
Expand All @@ -23,12 +22,15 @@
import io.pslab.R;
import io.pslab.communication.ScienceLab;
import io.pslab.fragment.LALogicLinesFragment;
import io.pslab.models.LogicAnalyzerData;
import io.pslab.others.LocalDataLog;
import io.pslab.others.MathUtils;
import io.pslab.others.ScienceLabCommon;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.pslab.others.SwipeGestureDetector;
import io.realm.RealmResults;

/**
* Created by viveksb007 on 10/5/17.
Expand Down Expand Up @@ -56,6 +58,11 @@ public class LogicalAnalyzerActivity extends AppCompatActivity {
private GestureDetector gestureDetector;
private TextView showText;
private boolean btnLongpressed;
private final String KEY_LOG = "has_log";
private final String DATA_BLOCK = "data_block";
public boolean isPlayback = false;
public RealmResults<LogicAnalyzerData> recordedLAData;


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down Expand Up @@ -124,6 +131,12 @@ public boolean onTouch(View v, MotionEvent event) {
return true;
}
});

if (getIntent().getExtras() != null && getIntent().getExtras().getBoolean(KEY_LOG)) {
recordedLAData = LocalDataLog.with()
.getBlockOfLARecords(getIntent().getExtras().getLong(DATA_BLOCK));
isPlayback = true;
}
}

@Override
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/io/pslab/adapters/SensorLoggerListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.pslab.activity.BarometerActivity;
import io.pslab.activity.CompassActivity;
import io.pslab.activity.GyroscopeActivity;
import io.pslab.activity.LogicalAnalyzerActivity;
import io.pslab.activity.LuxMeterActivity;
import io.pslab.activity.MapsActivity;
import io.pslab.activity.MultimeterActivity;
Expand All @@ -39,6 +40,7 @@
import io.pslab.models.BaroData;
import io.pslab.models.GyroData;
import io.pslab.models.CompassData;
import io.pslab.models.LogicAnalyzerData;
import io.pslab.models.LuxData;
import io.pslab.models.MultimeterData;
import io.pslab.models.OscilloscopeData;
Expand Down Expand Up @@ -125,6 +127,10 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
holder.sensor.setText(R.string.multimeter);
holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.tile_icon_multimeter));
break;
case PSLabSensor.LOGIC_ANALYZER:
holder.sensor.setText(R.string.logical_analyzer);
holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.tile_icon_logic_analyzer));
break;
default:
break;
}
Expand Down Expand Up @@ -205,6 +211,11 @@ private void handleCardViewClick(SensorDataBlock block) {
multimeter.putExtra(KEY_LOG, true);
multimeter.putExtra(DATA_BLOCK, block.getBlock());
context.startActivity(multimeter);
} else if (block.getSensorType().equalsIgnoreCase(context.getResources().getString(R.string.logical_analyzer))) {
Intent laIntent = new Intent(context, LogicalAnalyzerActivity.class);
laIntent.putExtra(KEY_LOG, true);
laIntent.putExtra(DATA_BLOCK, block.getBlock());
context.startActivity(laIntent);
}
}

Expand Down Expand Up @@ -244,6 +255,8 @@ public void onClick(DialogInterface dialog, int whichButton) {
LocalDataLog.with().clearBlockOfPowerRecords(block.getBlock());
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.MULTIMETER)) {
LocalDataLog.with().clearBlockOfMultimeterRecords(block.getBlock());
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.LOGIC_ANALYZER)) {
LocalDataLog.with().clearBlockOfLARecords(block.getBlock());
}
LocalDataLog.with().clearSensorBlock(block.getBlock());
dialog.dismiss();
Expand Down Expand Up @@ -461,6 +474,25 @@ private void populateMapData(SensorDataBlock block) {
}
}
setMapDataToIntent(array);
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.LOGIC_ANALYZER)) {
RealmResults<LogicAnalyzerData> data = LocalDataLog.with().getBlockOfLARecords(block.getBlock());
JSONArray array = new JSONArray();
for (LogicAnalyzerData d : data) {
try {
JSONObject i = new JSONObject();
i.put("date", CSVLogger.FILE_NAME_FORMAT.format(d.getTime()));
i.put("channel", d.getChannel());
i.put("channel_mode", d.getChannelMode());
i.put("xaxis", d.getDataX());
i.put("yaxis", d.getDataY());
i.put("lat", d.getLat());
i.put("lon", d.getLon());
if (d.getLat() != 0.0 && d.getLon() != 0.0) array.put(i);
} catch (JSONException e) {
e.printStackTrace();
}
}
setMapDataToIntent(array);
}
}

Expand Down
Loading