-
Notifications
You must be signed in to change notification settings - Fork 815
feat: added csv import/export for robotic arm #2807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideImplements CSV import/export for the robotic arm by integrating a CsvService in the state provider, adding UI dialogs and menu actions in RoboticArmScreen to trigger export/import operations with filename input and feedback, and updating LoggedDataScreen to return CSV data directly for robotic arm instead of chart navigation. Sequence diagram for robotic arm CSV export processsequenceDiagram
actor User
participant RoboticArmScreen
participant RoboticArmStateProvider
participant CsvService
User->>RoboticArmScreen: Tap save icon
RoboticArmScreen->>User: Show filename dialog
User->>RoboticArmScreen: Enter filename and confirm
RoboticArmScreen->>RoboticArmStateProvider: exportTimelineToCsv(filename)
RoboticArmStateProvider->>CsvService: saveCsvFile(...)
CsvService-->>RoboticArmStateProvider: File saved
RoboticArmStateProvider-->>RoboticArmScreen: Success/failure
RoboticArmScreen->>User: Show snackbar with result
Sequence diagram for robotic arm CSV import processsequenceDiagram
actor User
participant RoboticArmScreen
participant LoggedDataScreen
participant RoboticArmStateProvider
User->>RoboticArmScreen: Open menu, select 'Show Logged Data'
RoboticArmScreen->>LoggedDataScreen: Navigate to
User->>LoggedDataScreen: Select CSV file
LoggedDataScreen-->>RoboticArmScreen: Return CSV data
RoboticArmScreen->>RoboticArmStateProvider: importTimelineFromCsv(data)
RoboticArmStateProvider-->>RoboticArmScreen: Update timeline
RoboticArmScreen->>User: Updated timeline displayed
Class diagram for CSV import/export integration in RoboticArmStateProviderclassDiagram
class RoboticArmStateProvider {
+Future<void> exportTimelineToCsv(String instrumentName, String fileName)
+Future<void> importTimelineFromCsv(List<List<dynamic>> csv)
-CsvService _csvService
List<List<double?>> timelineDegrees
}
class CsvService {
+Future<void> saveCsvFile(String instrumentName, String fileName, List<List<dynamic>> data)
+Future<List<List<dynamic>>> readCsvFromFile(File file)
+Future<List<List<dynamic>>?> pickAndReadCsvFile()
}
RoboticArmStateProvider --> CsvService : uses
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rahul31124 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `lib/providers/robotic_arm_state_provider.dart:228` </location>
<code_context>
+
+ final dateFormat = DateFormat('yyyy-MM-dd HH:mm:ss.SSS');
+
+ for (int i = 0; i < timelineDegrees.length; i++) {
+ final row = timelineDegrees[i];
+ final timestamp = i;
+ final dateTime = dateFormat.format(DateTime.now());
+
+ csvData.add([
</code_context>
<issue_to_address>
DateTime.now() used for each row may not reflect actual timeline data.
Consider moving DateTime.now() outside the loop if you want a single export timestamp, or use the actual data's timestamp for each row if available.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
final dateFormat = DateFormat('yyyy-MM-dd HH:mm:ss.SSS');
for (int i = 0; i < timelineDegrees.length; i++) {
final row = timelineDegrees[i];
final timestamp = i;
final dateTime = dateFormat.format(DateTime.now());
csvData.add([
timestamp,
row[0]?.toString() ?? 'null',
row[1]?.toString() ?? 'null',
row[2]?.toString() ?? 'null',
row[3]?.toString() ?? 'null',
dateTime
]);
}
=======
final dateFormat = DateFormat('yyyy-MM-dd HH:mm:ss.SSS');
final exportDateTime = dateFormat.format(DateTime.now());
for (int i = 0; i < timelineDegrees.length; i++) {
final row = timelineDegrees[i];
final timestamp = i;
csvData.add([
timestamp,
row[0]?.toString() ?? 'null',
row[1]?.toString() ?? 'null',
row[2]?.toString() ?? 'null',
row[3]?.toString() ?? 'null',
exportDateTime
]);
}
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `lib/providers/robotic_arm_state_provider.dart:247` </location>
<code_context>
+ }
+
+ Future<void> importTimelineFromCsv(List<List<dynamic>> csv) async {
+ if (csv.length <= 2) return;
+
+ final dataRows = csv.skip(1).toList();
</code_context>
<issue_to_address>
Header skipping logic may be off by one.
The guard clause may prevent processing a CSV with only one data row. Consider changing the check to csv.length <= 1 to ensure single-row CSVs are handled.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
Future<void> importTimelineFromCsv(List<List<dynamic>> csv) async {
if (csv.length <= 2) return;
final dataRows = csv.skip(1).toList();
=======
Future<void> importTimelineFromCsv(List<List<dynamic>> csv) async {
if (csv.length <= 1) return;
final dataRows = csv.skip(1).toList();
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Build successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/16859650865/artifacts/3728452393 |
Changes
Recording
robotic_arm_csv.webm
Checklist:
strings.xml
,dimens.xml
andcolors.xml
without hard coding any value.strings.xml
,dimens.xml
orcolors.xml
.Summary by Sourcery
Add CSV import and export capabilities for the robotic arm timeline, including UI prompts for file naming, provider methods for CSV handling, and integration with the logged data screen to load external CSVs.
New Features:
Enhancements: