Skip to content
Permalink
Browse files

Fixed code to properly import configuration from configuration file u…

…sing Config::Simplei
  • Loading branch information...
rkoeppl committed May 1, 2016
1 parent 4d30ff7 commit ea25a17dac65d59de2b1d30dccf666afa6079c81
Showing with 100 additions and 45 deletions.
  1. +39 −39 modules/printengine.cfg
  2. +61 −6 modules/printengine.pl
@@ -6,44 +6,44 @@
#released under the MIT License
#this piece of software is provided with absolutely no warranty
#use at your own risk
my $log_file = "../log/printengine.log";
my $logging_enabled="TRUE";
my $controllerboard="BBB";
my $steps_per_mm=100; #steps needed to move the Z-Axis 1mm
my $projector_type="Lightcrafter4500"; #default Light engine
my $projector_usb_device="";
my $endstop_Z_max=TRUE;
my $endstop_Z_max_type="NC";#NO="Normally Open", NC="Normally Closed". NC is preferred
my $endstop_Z_min=TRUE;
my $endstop_Z_min_type="NC";#NO="Normally Open", NC="Normally Closed". NC is preferred
my $wiper="FALSE";
my $door_contact="true"; Defines if there is a door contact to determine if the enclosure is closed
my $X_pixels="1192";
my $Y_pixels="948";
my $Z_Autocal="True"; #Automatically determine Z-travel by triggering both endstops and dividing the Distance
my $testrun_capable="true"; Capability to run testruns with wavelengthe that do not trigger polymerisation
my $testrun_color="RED"; #Color channel used for test run
my $prodrun_color="BLUE"; #Color Channel used for production run
my $vat_heatable="false";
my $check_vat_presence="false";
log_file = "../log/printengine.log";
logging_enabled="TRUE";
controllerboard="BBB";
steps_per_mm=100; #steps needed to move the Z-Axis 1mm
projector_type="Lightcrafter4500"; #default Light engine
projector_usb_device="";
endstop_Z_max=TRUE;
endstop_Z_max_type="NC";#NO="Normally Open", NC="Normally Closed". NC is preferred
endstop_Z_min=TRUE;
endstop_Z_min_type="NC";#NO="Normally Open", NC="Normally Closed". NC is preferred
wiper="FALSE";
door_contact="true"; Defines if there is a door contact to determine if the enclosure is closed
X_pixels="1192";
Y_pixels="948";
Z_Autocal="True"; #Automatically determine Z-travel by triggering both endstops and dividing the Distance
testrun_capable="true"; Capability to run testruns with wavelengthe that do not trigger polymerisation
testrun_color="RED"; #Color channel used for test run
prodrun_color="BLUE"; #Color Channel used for production run
vat_heatable="false";
vat_target_temperature="";#Vat temperature in Celsius
check_vat_presence="false";
#board specific configuration for Beaglebone Black
if ($controllerboard eq "BBB") then {
my $virtual_terminal=1;
my $display_software="fbi";
my $display_device="/dev/fb0";
virtual_terminal=1;
display_software="fbi";
display_device="/dev/fb0";
#PIN asignment
my $pin_zmin="";
my $pin_zmax="";
my $pin_door="";
my $pin_step_Z="";
my $pin_enable_Z="";
my $pin_direction_Z="";
my $pin_trigger_pre="";
my $pin_trigger_post="";
my $pin_enable_wiper="";
my $pin_dir_wiper="";
my $pin_step_wiper="";
my $pin_vat_heater="";
my $pin_vat_temperature="";
my $pin_vat_presence="";
}
pin_zmin="";
pin_zmax="";
pin_door="";
pin_step_Z="";
pin_enable_Z="";
pin_direction_Z="";
pin_trigger_pre="";
pin_trigger_post="";
pin_enable_wiper="";
pin_dir_wiper="";
pin_step_wiper="";
pin_vat_heater="";
pin_vat_temperature="";
pin_vat_presence="";
#end of BBB specifics
67 modules/printengine.pl 100644 → 100755
@@ -6,28 +6,83 @@
#released under the MIT License
#this piece of software is provided with absolutely no warranty
#use at your own risk
#configuration is stored in printengine.cfg, do not use hardcoded configuration in ths per script, that is bad practice.
use warning;
#configuration is stored in printengine.cfg, do not use hardcoded configuration in ths perl script, that is bad practice.
use warnings;
use strict;
use Getopt::Std;
use Getopt::Long;
use feature qw(say);
use Config::Simple;
my $cfg = new Config::Simple('printengine.cfg');
$cfg->read('printengine.cfg');
#asign config values from config file to values in script
my $log_file = $cfg->param("log_file");
my $logging_enabled=$cfg->param("logging_enabled");
my $controllerboard=$cfg->param("controllerboard");
my $steps_per_mm=$cfg->param("steps_per_mm");
my $projector_type=$cfg->param("projector_type");
my $projector_usb_device=$cfg->param("projector_usb_device");
my $endstop_Z_max=$cfg->param("endstop_Z_max");
my $endstop_Z_max_type=$cfg->param("endstop_Z_max_type");
my $endstop_Z_min=$cfg->param("endstop_Z_min");
my $endstop_Z_min_type=$cfg->param("endstop_Z_min_type");
my $wiper=$cfg->param("wiper");
my $door_contact=$cfg->param("door_contact");
my $X_pixels=$cfg->param("X_pixels");
my $Y_pixels=$cfg->param("Y_pixels");
my $Z_Autocal=$cfg->param("Z-Z_Autocal");
my $testrun_capable=$cfg->param("testrun_capable");
my $testrun_color=$cfg->param("testrun_color");
my $prodrun_color=$cfg->param("prodrun_color");
my $vat_heatable=$cfg->param("vat_heatable");
my $vat_target_temperature=$cfg->param("vat_target_temperature");
my $check_vat_presence=$cfg->param("check_vat_presence");
my $virtual_terminal=$cfg->param("virtual_terminal");
my $display_software=$cfg->param("display_software");
my $display_device=$cfg->param("display_device");
my $pin_zmin=$cfg->param("pin_zmin");
my $pin_zmax=$cfg->param("pin_zmax");
my $pin_door=$cfg->param("pin_door");
my $pin_step_Z=$cfg->param("pin_step_Z");
my $pin_enable_Z=$cfg->param("pin_enable_Z");
my $pin_direction_Z=$cfg->param("pin_direction_Z");
my $pin_trigger_pre=$cfg->param("pin_trigger_pre");
my $pin_trigger_post=$cfg->param("pin_trigger_post");
my $pin_enable_wiper=$cfg->param("pin_enable_wiper");
my $pin_dir_wiper=$cfg->param("pin_dir_wiper");
my $pin_step_wiper=$cfg->param("pin_step_wiper");
my $pin_vat_heater=$cfg->param("pin_vat_heater");
my $pin_vat_temperature=$cfg->param("pin_vat_temperature");
my $pin_vat_presence=$cfg->param("pin_vat_presence");


#include configuration and settings from printengine.cfg
use printengine.cfg
#checked for used controller board type according to configuration.
#activate logging to logfile
if $logging_enabled eq "TRUE" then
if ($logging_enabled eq "TRUE")
{
open my $log_fh, ">", $log_file;
}

if $controllerboard eq "BBB" then
if ($controllerboard eq "BBB")
{

}
else {
say "unknows printer type $controllerboard , please review your configuration, get in touch with developers or fork the code on Github and contribute the code to use the new printer"
;
die "unknown board in configuration!\n";
}

if ($display_software eq "fbi")
{
open(whichfile,"which $display_software |") || die "Failed: $!\n";
while ( <whichfile> )
{
my $display_software_path=$!;
}
}
else {
say "unknows display software $display_software , please review your configuration, get in touch with developers or fork the code on Github and contribute the code to use the new printer"
;
die "unknown display software in configuration!\n";
}

0 comments on commit ea25a17

Please sign in to comment.
You can’t perform that action at this time.