Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pousseseringue-arduino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FabLAAS
PousseSeringue
pousseseringue-arduino
Commits
1c3c87df
Commit
1c3c87df
authored
Aug 23, 2023
by
Malaurie Bernard
Browse files
Options
Downloads
Patches
Plain Diff
Fix cli interface
parent
ffd54be7
Branches
Branches containing commit
No related tags found
1 merge request
!17
Malaurie's work on UI + CLI interface + AccelStepper interface
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cli.cpp
+122
-37
122 additions, 37 deletions
cli.cpp
with
122 additions
and
37 deletions
cli.cpp
+
122
−
37
View file @
1c3c87df
...
...
@@ -79,7 +79,7 @@ void Cli::syntax (const char* cmd)
if
(
!
cmd
||
kw
(
F
(
"AT"
),
cmd
))
Serial
.
printf
(
"%sAT -> OK
\n
"
,
_msgHeader
);
if
(
!
cmd
||
kw
(
F
(
"HELP"
),
cmd
))
Serial
.
printf
(
"%sHELP [CMD]
\n
"
,
_msgHeader
);
if
(
!
cmd
||
kw
(
F
(
"RAT"
),
cmd
))
Serial
.
printf
(
"%sRAT [ C <rate> [<unit>] ] - set or show rate ([UM]/MM/UH/MH)
\n
"
,
_msgHeader
);
if
(
!
cmd
||
kw
(
F
(
"VOL"
),
cmd
))
Serial
.
printf
(
"%sVOL [ <vol>
]
- set the volume to exchange in mL
\n
"
,
_msgHeader
);
if
(
!
cmd
||
kw
(
F
(
"VOL"
),
cmd
))
Serial
.
printf
(
"%sVOL [ <vol>
| <unit> ]
- set the volume to exchange in mL
\n
"
,
_msgHeader
);
if
(
!
cmd
||
kw
(
F
(
"RVOL"
),
cmd
))
Serial
.
printf
(
"%sRVOL <vol> - set relative volume to exchange in mL
\n
"
,
_msgHeader
);
if
(
!
cmd
||
kw
(
F
(
"MM"
),
cmd
))
Serial
.
printf
(
"%sMM [ <len> ] - set final position in mm
\n
"
,
_msgHeader
);
if
(
!
cmd
||
kw
(
F
(
"RMM"
),
cmd
))
Serial
.
printf
(
"%sRMM <len> - set relative distance to browse in mm
\n
"
,
_msgHeader
);
...
...
@@ -117,6 +117,7 @@ void Cli::check_emergency ()
void
Cli
::
loop
(
Stream
&
input
)
{
while
(
true
)
{
if
(
!
input
.
available
())
...
...
@@ -145,64 +146,109 @@ void Cli::loop (Stream& input)
else
syntax
();
}
else
if
(
kw
(
F
(
"RAT"
)))
//*******************RATE*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
copyNextToTemp
();
if
(
_temp
.
equalsIgnoreCase
(
F
(
"C"
)))
{
copyNextToTemp
();
syringe_filled
.
set_exchange_throughput_uL_per_sec
(
atof
(
_temp
.
c_str
()));
syringe_filled
.
set_exchange_throughput_uL_per_min
(
atof
(
_temp
.
c_str
()));
copyNextToTemp
();
if
(
_temp
.
equalsIgnoreCase
(
F
(
"us"
)))
syringe_filled
.
set_exchange_throughput_uL_per_min
(
syringe_filled
.
get_exchange_throughput_uL_per_min
()
/
60
);
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"ms"
)))
syringe_filled
.
set_exchange_throughput_uL_per_min
(
syringe_filled
.
get_exchange_throughput_uL_per_min
()
*
1000
/
60
);
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"um"
)))
;
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"mm"
)))
syringe_filled
.
set_exchange_throughput_uL_per_min
(
syringe_filled
.
get_exchange_throughput_uL_per_min
()
*
1000
);
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"uh"
)))
syringe_filled
.
set_exchange_throughput_uL_per_min
(
syringe_filled
.
get_exchange_throughput_uL_per_min
()
/
60
);
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"mh"
)))
syringe_filled
.
set_exchange_throughput_uL_per_min
(
syringe_filled
.
get_exchange_throughput_uL_per_min
()
*
1000
/
60
);
else
syringe_filled
.
set_exchange_throughput_uL_per_min
(
-
1
);
answer
(
syringe_filled
.
check_configuration
(),
F
(
"invalid 'RAT C rate uL'"
));
}
else
if
(
_temp
.
length
()
>
0
)
answer
(
false
,
F
(
"RAT must be followed by C"
));
Serial
.
printf
(
"%sRAT: %g ul/mn
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_throughput_uL_per_min
()
*
60
);
Serial
.
printf
(
"%sRAT: %g ul/mn
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_throughput_uL_per_min
());
}
else
if
(
kw
(
F
(
"VOL"
)))
//*******************EXCHANGE_VOLUME*******************//
{
copyNextToTemp
();
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
get_remaining_volume_mL
()
-
stof
(
_temp
.
c_str
()));
answer
(
syringe_filled
.
check_configuration
(),
F
(
"invalid exchange volume"
));
syringe_filled
.
set_name_syringe
(
"cli"
);
Serial
.
printf
(
"%sVOL: %g ul (target)
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_volume_mL
());
copyNextToTemp
();
while
(
_temp
.
length
())
{
if
(
isdigit
(
_temp
[
0
]))
{
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
distance_mm_to_volume_mL
(
syringe_filled
.
step_to_mm
(
syringe_filled
.
where_step
()))
-
stof
(
_temp
.
c_str
()));
syringe_filled
.
save_json
();
Serial
.
println
(
"ok"
);
}
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"ul"
)))
;
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"ml"
)))
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
get_exchange_volume_mL
()
*
1000
);
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"cl"
)))
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
get_exchange_volume_mL
()
*
10000
);
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"dl"
)))
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
get_exchange_volume_mL
()
*
100000
);
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"l"
)))
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
get_exchange_volume_mL
()
*
1000000
);
syringe_filled
.
save_json
();
answer
(
syringe_filled
.
check_configuration
(),
F
(
"invalid volume or volume unit"
));
copyNextToTemp
();
}
}
else
if
(
kw
(
F
(
"RVOL"
)))
//*******************RELATIVE_EXCHANGE_VOLUME*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
syringe_filled
.
reset_position
();
copyNextToTemp
();
while
(
_temp
.
length
())
{
if
(
isdigit
(
_temp
[
0
])
||
_temp
[
0
]
==
'-'
)
{
syringe_filled
.
set_exchange_volume_mL
(
atof
(
_temp
.
c_str
()));
syringe_filled
.
save_json
();
}
answer
(
syringe_filled
.
check_configuration
(),
F
(
"invalid exchange volume"
));
copyNextToTemp
();
}
Serial
.
printf
(
"%sRVOL: %g
u
l (target)
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_volume_mL
());
Serial
.
printf
(
"%sRVOL: %g
m
l (target)
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_volume_mL
());
}
else
if
(
kw
(
F
(
"MM"
)))
//*******************DISTANCE_TO_ZERO*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
copyNextToTemp
();
if
(
_temp
.
length
())
{
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
distance_mm_to_volume_mL
(
atof
(
_temp
.
c_str
())));
printf
(
"okkk"
);
//answer(syringe_filled.check_configuration(), F("invalid length"));
if
(
isdigit
(
_temp
[
0
])
||
_temp
[
0
]
==
'-'
)
syringe_filled
.
set_exchange_volume_mL
(
syringe_filled
.
distance_mm_to_volume_mL
(
syringe_filled
.
step_to_mm
(
syringe_filled
.
where_step
()))
+
syringe_filled
.
distance_mm_to_volume_mL
(
atof
(
_temp
.
c_str
())));
answer
(
syringe_filled
.
check_configuration
(),
F
(
"invalid length"
));
copyNextToTemp
();
}
syringe_filled
.
save_json
();
Serial
.
printf
(
"%sMM: %g ml (%g mm) (target)
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_volume_mL
(),
syringe_filled
.
volume_mL_to_distance_mm
(
syringe_filled
.
get_exchange_volume_mL
()));
Serial
.
printf
(
"%sMM: %d ul (%d mm) (target)
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_volume_mL
(),
syringe_filled
.
volume_mL_to_distance_mm
(
syringe_filled
.
get_exchange_volume_mL
()));
}
else
if
(
kw
(
F
(
"RMM"
)))
//*******************RELATIVE_DISTANCE*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
copyNextToTemp
();
if
(
_temp
.
length
())
{
...
...
@@ -211,36 +257,48 @@ void Cli::loop (Stream& input)
answer
(
syringe_filled
.
check_configuration
(),
F
(
"invalid exchange length"
));
copyNextToTemp
();
}
syringe_filled
.
save_json
();
Serial
.
printf
(
"%sRMM: %g ml (%g mm) (target)
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_volume_mL
(),
syringe_filled
.
volume_mL_to_distance_mm
(
syringe_filled
.
get_exchange_volume_mL
()));
Serial
.
printf
(
"%sRMM: %g ul (%g mm) (target)
\n
"
,
_msgHeader
,
syringe_filled
.
get_exchange_volume_mL
(),
syringe_filled
.
volume_mL_to_distance_mm
(
syringe_filled
.
get_exchange_volume_mL
()));
}
#if 0
else
if
(
kw
(
F
(
"DIA"
)))
//*******************INTERNAL_DIAMETER*******************//*
{
syringe_filled
.
set_name_syringe
(
"cli"
);
String name_syringe = syringe_filled.get_syringe_filled_data()["name_syringe"];
copyNextToTemp
();
if
(
_temp
.
length
())
{
syringe.get_syringe_database()[name_syringe].set_internal_diameter_mm(name_syringe,atof(_temp.c_str()));
answer( syringe.check_configuration(name_syringe), F("invalid diameter"));
syringe
.
set_internal_diameter_mm
(
"cli"
,
atof
(
_temp
.
c_str
()));
syringe
.
save_json
();
answer
(
syringe
.
check_configuration
(
"cli"
),
F
(
"invalid diameter"
));
}
Serial.printf("%sDIA: %g mm\n", _msgHeader, syringe.get_
syringe_database()[name_syringe]["
internal_diameter_mm
"]
);
Serial
.
printf
(
"%sDIA: %g mm
\n
"
,
_msgHeader
,
syringe
.
get_internal_diameter_mm
(
"cli"
)
);
}
#endif
else
if
(
kw
(
F
(
"RVM"
)))
{
//syringe_filled.set_name_syringe("cli");
copyNextToTemp
();
if
(
_temp
==
F
(
"M4"
))
syringe_filled
.
set_mm_per_revolution
(
M4_MMREV
);
{
syringe_filled
.
set_lead_screw_pitch_mm
(
0.7
);
syringe_filled
.
save_json
();
}
else
if
(
_temp
==
F
(
"M5"
))
syringe_filled
.
set_mm_per_revolution
(
M5_MMREV
);
{
syringe_filled
.
set_lead_screw_pitch_mm
(
0.8
);
syringe_filled
.
save_json
();
}
else
if
(
_temp
.
length
()
>
0
)
answer
(
false
,
F
(
"invalid auger size: M4 or M5 are accepted"
));
Serial
.
printf
(
"%sRVM: %g mm per revolution
\n
"
,
_msgHeader
,
syringe_filled
.
get_
mm_per_revolution
());
Serial
.
printf
(
"%sRVM: %g mm per revolution
\n
"
,
_msgHeader
,
syringe_filled
.
get_
lead_screw_pitch_mm
());
}
else
if
(
kw
(
F
(
"ACC"
)))
//*******************ACCELERATION*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
copyNextToTemp
();
if
(
_temp
.
length
())
syringe_filled
.
set_retain_acceleration_mm_per_sec_per_sec
(
atof
(
_temp
.
c_str
()));
...
...
@@ -248,13 +306,21 @@ void Cli::loop (Stream& input)
}
else
if
(
kw
(
F
(
"DIR"
)))
//*******************DIRECTION*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
copyNextToTemp
();
if
(
_temp
.
length
())
{
if
(
_temp
.
equalsIgnoreCase
(
F
(
"inf"
)))
{
syringe_filled
.
set_push
(
true
);
syringe_filled
.
save_json
();
}
else
if
(
_temp
.
equalsIgnoreCase
(
F
(
"wdr"
)))
{
syringe_filled
.
set_push
(
false
);
syringe_filled
.
save_json
();
}
answer
(
syringe_filled
.
check_configuration
(),
F
(
"invalid direction -> INF | WDR"
));
}
Serial
.
printf
(
"%sDIR: %s
\n
"
,
_msgHeader
,
...
...
@@ -262,45 +328,60 @@ void Cli::loop (Stream& input)
}
else
if
(
kw
(
F
(
"FIL"
)))
//*******************MOUVEMENT*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
check_emergency
();
syringe_filled
.
start_exchange
();
answer
(
true
);
}
else
if
(
kw
(
F
(
"STP"
)))
{
syringe_filled
.
set_name_syringe
(
"cli"
);
syringe_filled
.
stop
();
answer
(
true
);
}
else
if
(
kw
(
F
(
"SET0"
)))
{
syringe_filled
.
set_name_syringe
(
"cli"
);
syringe_filled
.
reset_position
();
answer
(
true
);
}
else
if
(
kw
(
F
(
"DIS"
)))
//*******************DISTANCE_PARCOURU*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
Serial
.
printf
(
"%sDIS: I %g W %g UL
\n
"
,
_msgHeader
,
syringe_filled
.
get_push
()
?
syringe_filled
.
distance_mm_to_volume_mL
(
syringe_filled
.
step_to_mm
(
syringe_filled
.
where_step
()))
:
0
,
syringe_filled
.
get_push
()
?
0
:
syringe_filled
.
distance_mm_to_volume_mL
(
syringe_filled
.
step_to_mm
(
syringe_filled
.
where_step
())));
}
else
if
(
kw
(
F
(
"ZERO"
)))
//*******************ZERO*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
check_emergency
();
syringe_filled
.
go_to_limit_switch
();
answer
(
true
);
}
else
if
(
kw
(
F
(
"NLCK"
)))
//*******************RUN_FROM_EMERGENCY*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
syringe_filled
.
run_from_emergency
();
answer
(
true
);
}
else
if
(
kw
(
F
(
"CLKW"
)))
//*******************CLOCKWISE_EQUALS_PUSH*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
copyNextToTemp
();
if
(
_temp
.
length
()
==
1
)
{
if
(
_temp
[
0
]
==
'0'
||
_temp
[
0
]
==
'1'
)
{
syringe_filled
.
set_clockwise_equals_push
(
_temp
[
0
]
==
'1'
);
syringe_filled
.
save_json
();
answer
(
true
);
}
else
...
...
@@ -310,6 +391,8 @@ void Cli::loop (Stream& input)
}
else
if
(
kw
(
F
(
"CONF"
)))
//*******************SHOW_CONFIGURATION*******************//
{
syringe_filled
.
set_name_syringe
(
"cli"
);
syringe_filled
.
show_configuration
();
answer
(
true
);
}
...
...
@@ -331,15 +414,17 @@ void Cli::loop (Stream& input)
}
else
if
(
kw
(
F
(
"FS-SAVE"
)))
//*******************SAVE_THE_JSON_FILES*******************//
{
syringe
.
write_Json
();
syringe_filled
.
write_Json
();
syringe
.
save_json
();
syringe_filled
.
save_json
();
answer
(
true
);
}
else
if
(
kw
(
F
(
"FS-LOAD"
)))
//*******************LOAD_THE_JSON_FILES*******************//
{
syringe
.
read_Json
();
syringe_filled
.
read_Json
();
syringe
.
load_json
();
syringe_filled
.
load_json
();
answer
(
true
);
}
else
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment