|
|
|
@ -48,7 +48,7 @@ macro_rules! command {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
macro_rules! commands {
|
|
|
|
|
($($(#[$outer:meta])* $commandName: ident {$letter: pat, $number: pat, $fraction: pat, {$($(#[$inner:meta])* $argument: ident), *} },)*) => {
|
|
|
|
|
($($(#[$outer:meta])* $commandName: ident {$letter: expr, $number: expr, $fraction: path, {$($(#[$inner:meta])* $argument: ident), *} },)*) => {
|
|
|
|
|
|
|
|
|
|
/// Commands are the operational unit of GCode
|
|
|
|
|
/// They consist of an identifying word followed by arguments
|
|
|
|
@ -58,7 +58,6 @@ macro_rules! commands {
|
|
|
|
|
arguments: Vec<Word>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paste::item! {
|
|
|
|
|
impl Command {
|
|
|
|
|
pub fn new(command_word: CommandWord, mut arguments: Vec<Word>) -> Self {
|
|
|
|
|
Self {
|
|
|
|
@ -87,9 +86,7 @@ macro_rules! commands {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paste::item! {
|
|
|
|
|
impl Into<Vec<Word>> for Command {
|
|
|
|
|
fn into(self) -> Vec<Word> {
|
|
|
|
|
let mut args = self.arguments;
|
|
|
|
@ -97,9 +94,7 @@ macro_rules! commands {
|
|
|
|
|
args
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paste::item! {
|
|
|
|
|
impl TryFrom<&[Word]> for Command {
|
|
|
|
|
type Error = ();
|
|
|
|
|
fn try_from(words: &[Word]) -> Result<Self, ()> {
|
|
|
|
@ -125,7 +120,6 @@ macro_rules! commands {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, PartialEq, Eq)]
|
|
|
|
|
pub enum CommandWord {
|
|
|
|
@ -141,7 +135,6 @@ macro_rules! commands {
|
|
|
|
|
Checksum(u8),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paste::item! {
|
|
|
|
|
impl CommandWord {
|
|
|
|
|
pub fn is_command(word: &Word) -> bool {
|
|
|
|
|
let (number, fraction) = match &word.value {
|
|
|
|
@ -156,8 +149,7 @@ macro_rules! commands {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
paste::item! {
|
|
|
|
|
|
|
|
|
|
impl TryFrom<&Word> for CommandWord {
|
|
|
|
|
type Error = ();
|
|
|
|
|
fn try_from(word: &Word) -> Result<Self, ()> {
|
|
|
|
@ -173,8 +165,7 @@ macro_rules! commands {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
paste::item!{
|
|
|
|
|
|
|
|
|
|
impl Into<Word> for CommandWord {
|
|
|
|
|
fn into(self) -> Word {
|
|
|
|
|
match self {
|
|
|
|
@ -200,7 +191,6 @@ macro_rules! commands {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|