Skip to content
Machine.py 2.61 KiB
Newer Older
Fabrice Salvaire's avatar
Fabrice Salvaire committed
####################################################################################################
#
Fabrice Salvaire's avatar
Fabrice Salvaire committed
# PythonicGcodeMachine - A Python G-code Toolkit
Fabrice Salvaire's avatar
Fabrice Salvaire committed
# Copyright (C) 2018 Fabrice Salvaire
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
####################################################################################################

Fabrice Salvaire's avatar
Fabrice Salvaire committed
"""Module to implement a basic G-code machine.
Fabrice Salvaire's avatar
Fabrice Salvaire committed
"""

####################################################################################################

__all__ = [
Fabrice Salvaire's avatar
Fabrice Salvaire committed
    'GcodeMachine',
Fabrice Salvaire's avatar
Fabrice Salvaire committed
]

####################################################################################################

Fabrice Salvaire's avatar
Fabrice Salvaire committed
from pathlib import Path as Path

from .Config import Config
from .Parser import GcodeParser, GcodeParserError

####################################################################################################

class GcodeMachine:

    PARSER_CLS = GcodeParser
Fabrice Salvaire's avatar
Fabrice Salvaire committed

    ##############################################

Fabrice Salvaire's avatar
Fabrice Salvaire committed
    def __init__(self):

        self._config = None
        self.load_config()

        self._parser = None
        self.setup_parser()

    ##############################################

    def load_config(self):

        data_path = Path(__file__).parent.joinpath('data')
        self._config = Config(
            execution_order=data_path.joinpath('rs274-execution-order.yaml'),
            gcodes=data_path.joinpath('rs274-gcodes.yaml'),
            letters=data_path.joinpath('rs274-word-starting-letter.yaml'),
            modal_groups=data_path.joinpath('rs274-modal-groups.yaml'),
            parameters=data_path.joinpath('rs274-default-parameter-file.yaml'),
        )

    ##############################################

    def setup_parser(self):

        self._parser = self.PARSER_CLS(machine=self)

    ##############################################

    @property
    def config(self):
        return self._config

    @property
    def parser(self):
        return self._parser

    ##############################################

    def reset():
        pass

    ##############################################