Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

handle multiple config versions #29

Open
wants to merge 17 commits into
base: 2_2_x
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions configs/Kossel_K25000.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[System]

machine_type = Kossel_K25000
version = 2.0

[Geometry]
# Delta
Expand Down
4 changes: 4 additions & 0 deletions configs/debrew.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[System]

version = 2.0

[Geometry]
# Delta
axis_config = 3
Expand Down
1 change: 1 addition & 0 deletions configs/kossel_mini.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[System]

machine_type = Kossel_mini
version = 2.0

[Geometry]
# Delta
Expand Down
1 change: 1 addition & 0 deletions configs/makerbot_cupcake.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[System]

machine_type = Makerbot_Cupcake
version = 2.0

[Geometry]
# 0 - Cartesian
Expand Down
2 changes: 2 additions & 0 deletions configs/maxcorexy.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[System]

version = 2.0

[Geometry]
# Core-XY
axis_config = 2
Expand Down
2 changes: 2 additions & 0 deletions configs/mendelmax.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[System]

version = 2.0

[Geometry]
# Cartesian XY
axis_config = 0
Expand Down
1 change: 1 addition & 0 deletions configs/prusa_i3.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[System]

machine_type = Prusa_I3
version = 2.0

[Geometry]
offset_x = -0.19
Expand Down
1 change: 1 addition & 0 deletions configs/prusa_i3_quad.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[System]

machine_type = Prusa_I3
version = 2.0

[Geometry]
offset_x = -0.19
Expand Down
1 change: 1 addition & 0 deletions configs/rostock_max_v2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[System]

machine_type = Roskock_Max_v2
version = 2.0

[Geometry]
# Delta
Expand Down
1 change: 1 addition & 0 deletions configs/series1.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ loglevel = 10
# Machine type is used by M115
# to identify the machine connected.
machine_type = Series 1 Pro
version = 2.0


[Geometry]
Expand Down
1 change: 1 addition & 0 deletions configs/testing_rev_A.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

[System]
loglevel = 10
version = 2.0

[Geometry]
axis_config = 0
Expand Down
1 change: 1 addition & 0 deletions configs/testing_rev_B.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

[System]
loglevel = 10
version = 2.0

[Geometry]
axis_config = 0
Expand Down
2 changes: 2 additions & 0 deletions configs/thing.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[System]

version = 2.0

[Geometry]
# Thing has H-belt
axis_config = 1
Expand Down
1 change: 1 addition & 0 deletions configs/thing_delta.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[System]

machine_type = Thing delta
version = 2.0

[Geometry]
# Delta
Expand Down
4 changes: 4 additions & 0 deletions configs/ultimaker_original.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[System]

version = 2.0

[Geometry]
travel_x = 0.2
travel_y = -0.2
Expand Down
189 changes: 0 additions & 189 deletions redeem/CascadingConfigParser.py

This file was deleted.

8 changes: 7 additions & 1 deletion redeem/Printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
from Delta import Delta
from PruInterface import PruInterface
from SDCardManager import SDCardManager
import os
import json
from six import iteritems

from configuration.RedeemConfig import RedeemConfig


class Printer:
AXES = "XYZEHABC"
Expand Down Expand Up @@ -108,6 +109,11 @@ def __init__(self):

self.sd_card_manager = SDCardManager()

# default. should be initialized later
# TODO : these should be passed into from constructor
self.config = RedeemConfig()
self.replicape_key = None

def add_slave(self, master, slave):
''' Make an axis copy the movement of another.
the slave will get the same position as the axis'''
Expand Down
27 changes: 10 additions & 17 deletions redeem/Redeem.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from Gcode import Gcode
from ColdEnd import ColdEnd
from PruFirmware import PruFirmware
from CascadingConfigParser import CascadingConfigParser
from Printer import Printer
from GCodeProcessor import GCodeProcessor
from PluginsController import PluginsController
Expand All @@ -69,6 +68,9 @@
from _version import __version__, __release_name__

# Global vars
from redeem.configuration import get_config_factory
from redeem.configuration.factories.ConfigFactoryV20 import ConfigFactoryV20

printer = None

# Default logging level is set to debug
Expand Down Expand Up @@ -101,29 +103,20 @@ def __init__(self, config_location="/etc/redeem"):
Alarm.executor = AlarmExecutor()
alarm = Alarm(Alarm.ALARM_TEST, "Alarm framework operational")

# check for config files
file_path = os.path.join(config_location,"default.cfg")
if not os.path.exists(file_path):
logging.error(file_path + " does not exist, this file is required for operation")
sys.exit() # maybe use something more graceful?

local_path = os.path.join(config_location,"local.cfg")
if not os.path.exists(local_path):
logging.info(local_path + " does not exist, Creating one")
os.mknod(local_path)
os.chmod(local_path, 0o777)

# Parse the config files.
printer.config = CascadingConfigParser(
[os.path.join(config_location,'default.cfg'),
os.path.join(config_location,'printer.cfg'),
os.path.join(config_location,'local.cfg')])

# Check the local and printer files
printer_path = os.path.join(config_location,"printer.cfg")
if os.path.exists(printer_path):
printer.config.check(printer_path)
printer.config.check(os.path.join(config_location,'local.cfg'))
config_files = [
os.path.join(config_location, 'printer.cfg'),
os.path.join(config_location, 'local.cfg')
]

config_factory = get_config_factory(config_files)
printer.config = config_factory.hydrate_config(config_files=config_files)

# Get the revision and loglevel from the Config file
level = self.printer.config.getint('System', 'loglevel')
Expand Down
Loading