rintcore 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,24 +2,62 @@ require 'rint_core/driver'
2
2
  require 'active_support/configurable'
3
3
 
4
4
  module RintCore
5
+ # Interface for directly intereacting with the printer.
5
6
  class Printer
6
7
  include RintCore::Driver
7
8
  include ActiveSupport::Configurable
8
9
 
9
- # Callbacks are typically given a string argument, usually the current line
10
+ # @!macro config_accessor
11
+ # @!attribute [rw] $1
12
+ # @return [String] port that the printer is connected to.
13
+ # @!attribute [rw] $2
14
+ # @return [Fixnum] baud rate that the printer communicates at, value is not checked against {baud_rates}.
15
+ # @!attribute [rw] $3
16
+ # @return [Hash<Proc>] procs that are called at places in the code that correlate with their key.
17
+ # @todo make a list of all the callbacks that are used
18
+ # @!attribute [rw] $4
19
+ # @return [String] the response or prefix the printer sends when it encounters an error.
20
+ # @!attribute [rw] $5
21
+ # @return [String] the response or prefix the printer attaches to debugging messages.
22
+ # @!attribute [rw] $6
23
+ # @return [Array] the response(s) or prefix(es) the printer sends when it has successfully started.
24
+ # @!attribute [rw] $7
25
+ # @return [Array] the response(s) or prefix(es) the printer sends when it has received or executed a command.
26
+ # @!attribute [rw] $8
27
+ # @return [Array] the sequences of character the printer sends when it is reporting temperature information.
28
+ # @!attribute [rw] $9
29
+ # @return [Array] the response(s) or prefix(es) the printer sends when it needs lines resent.
30
+ # @!attribute [rw] $10
31
+ # @return [String] the character set that the printer uses to communicate.
32
+ # @todo make this have an effect on received responses.
33
+ # @!attribute [rw] $11
34
+ # @return [Float] the amount of time to sleep while waiting for the line to become clear before sending.
35
+ # @!attribute [rw] $12
36
+ # @return [Fixnum] the number of times to sleep ({#sleep_time}) after sending a command.
37
+ # @!attribute [rw] $13
38
+ # @return [Fixnum] read timeout value for the serial port.
39
+ # @!attribute [rw] $14
40
+ # @return [Float] used in various places while waiting for responses from the printer.
41
+ # @!attribute [rw] $15
42
+ # @return [Float] speed multiplier (print moves only).
43
+ # @!attribute [rw] $16
44
+ # @return [Float] extrusion multiplier.
45
+ # @!attribute [rw] $17
46
+ # @return [Float] travel move multiplier.
10
47
  config_accessor :port, :baud, :callbacks, :error_response, :debug_response,
11
48
  :online_response, :good_response, :temperature_response,
12
49
  :resend_response, :encoding, :sleep_time, :wait_period,
13
- :read_timeout, :long_sleep
50
+ :read_timeout, :long_sleep, :speed_multiplier, :extrusion_multiplier,
51
+ :travel_multiplier
14
52
 
15
53
  self.port = "/dev/ttyACM0"
16
54
  self.baud = 115200
17
55
  self.callbacks = {}
18
- self.error_response = 'Error'
56
+ self.error_response = 'error'
19
57
  self.debug_response = 'DEBUG_'
20
58
  self.online_response = ['start','Grbl']
21
59
  self.good_response = ['ok']
22
- self.temperature_response = 'T:'
60
+ self.temperature_response = ['T:']
23
61
  self.resend_response = ['rs','resend']
24
62
  self.encoding = 'us-ascii'
25
63
  self.sleep_time = 0.001
@@ -27,15 +65,35 @@ module RintCore
27
65
  self.read_timeout = 0
28
66
  self.long_sleep = 0.25
29
67
 
68
+ # @!macro attr_reader
69
+ # @!attribute [r] $1
70
+ # @return [String] the last line read from the printer
71
+ # @!attribute [r] $2
72
+ # @return [Array] consists of raw strings of GCode or {GCode::Object}s
73
+ # @!attribute [r] $3
74
+ # @return [Fixnum] 0 if not printer, other wise indicates the position in {#main_queue}
75
+ # @!attribute [r] $4
76
+ # @return [Fixnum] normally -1, other wise indicates the position to resend data from in {#machine_history}.
77
+ # @!attribute [r] $5
78
+ # @return [Array] raw us-ascii strings that have been sent to the printer,
79
+ # array index reflects the line number, it is emptied upon print completion.
80
+ # @!attribute [r] $6
81
+ # @return [Array] raw us-ascii strings that have been sent to the printer since it has been connected.
82
+ # @todo make a method to clear the history
30
83
  attr_reader :last_line_received, :main_queue, :queue_index, :resend_from, :machine_history, :full_history
31
84
 
85
+ # Creates a new {Printer} instance.
86
+ # @param auto_connect [Boolean] if true, {#connect!} will be called.
87
+ # @return [Printer] a new instance of RintCore::Printer
32
88
  def initialize(auto_connect = false)
33
89
  initialize_driver
34
90
  connect! if auto_connect
35
91
  end
36
92
 
93
+ # Returns the time since a print has started in human readable format, returns "0 seconds" if not printing.
94
+ # @return [String] human readable time since print started, or "0 seconds" if not printing.
37
95
  def time_from_start
38
- @start_time ||= Time.now
96
+ @start_time = Time.now unless printing?
39
97
  secs = Time.now - @start_time
40
98
  [[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
41
99
  if secs > 0
@@ -46,10 +104,15 @@ module RintCore
46
104
  end
47
105
 
48
106
  class << self
107
+ # An array of standard serial port baud rates, useful for checking for a valid configuration.
108
+ # @return [Array] of standard serial port baud rates.
49
109
  def baud_rates
50
110
  [2400, 9600, 19200, 38400, 57600, 115200, 250000]
51
111
  end
52
112
 
113
+ # A function that checks if the given file exists and is a tty, useful for checking for a valid configuration.
114
+ # @param port [String] a path on the local file system.
115
+ # @return [Boolean] true if given path is a tty, false otherwise.
53
116
  def is_port?(port)
54
117
  port.present? && File.exist?(port) && File.new(port).isatty
55
118
  end
@@ -1,3 +1,4 @@
1
1
  module RintCore
2
- VERSION = "0.0.3"
2
+ # Current release version of the gem.
3
+ VERSION = "0.0.4"
3
4
  end
data/rintcore.gemspec CHANGED
@@ -7,19 +7,18 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "rintcore"
8
8
  gem.version = RintCore::VERSION
9
9
  gem.authors = ["Kaz Walker"]
10
- gem.email = ["kaz.walker@doopli.co"]
11
- gem.description = %q{RepRap/GCode utilities written in Ruby.}
12
- gem.summary = %q{A Ruby implementation of PrintCore.}
10
+ gem.email = ["kaz.walker@slipline.ca"]
11
+ gem.description = %q{A RepRap driver and GCode analyzer written in Ruby.}
12
+ gem.summary = %q{A Ruby implementation of Printrun's printcore.py and gcoder.py.}
13
13
  gem.homepage = "https://github.com/KazW/RintCore"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
17
  gem.require_paths = ["lib"]
19
18
  gem.required_ruby_version = '>= 1.9.1'
20
19
  gem.add_runtime_dependency 'serialport', '1.1.0'
21
20
  gem.add_runtime_dependency 'activesupport'
22
21
  gem.add_runtime_dependency 'thor'
23
22
  gem.add_development_dependency 'rake'
24
- gem.add_development_dependency 'rspec'
23
+ gem.add_development_dependency 'yard'
25
24
  end
metadata CHANGED
@@ -1,71 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rintcore
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Kaz Walker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2013-02-26 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2013-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: serialport
16
- type: :runtime
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "="
20
- - !ruby/object:Gem::Version
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
21
19
  version: 1.1.0
20
+ type: :runtime
22
21
  prerelease: false
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.0
27
+ - !ruby/object:Gem::Dependency
25
28
  name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
26
34
  type: :runtime
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - &id003
30
- - ">="
31
- - !ruby/object:Gem::Version
32
- version: "0"
33
35
  prerelease: false
34
- version_requirements: *id002
35
- - !ruby/object:Gem::Dependency
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
36
42
  name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
37
48
  type: :runtime
38
- requirement: &id004 !ruby/object:Gem::Requirement
39
- requirements:
40
- - *id003
41
49
  prerelease: false
42
- version_requirements: *id004
43
- - !ruby/object:Gem::Dependency
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
44
56
  name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
45
62
  type: :development
46
- requirement: &id005 !ruby/object:Gem::Requirement
47
- requirements:
48
- - *id003
49
63
  prerelease: false
50
- version_requirements: *id005
51
- - !ruby/object:Gem::Dependency
52
- name: rspec
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
53
76
  type: :development
54
- requirement: &id006 !ruby/object:Gem::Requirement
55
- requirements:
56
- - *id003
57
77
  prerelease: false
58
- version_requirements: *id006
59
- description: RepRap/GCode utilities written in Ruby.
60
- email:
61
- - kaz.walker@doopli.co
62
- executables:
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A RepRap driver and GCode analyzer written in Ruby.
84
+ email:
85
+ - kaz.walker@slipline.ca
86
+ executables:
63
87
  - rintcore
64
88
  extensions: []
65
-
66
89
  extra_rdoc_files: []
67
-
68
- files:
90
+ files:
69
91
  - .gitignore
70
92
  - CONTRIBUTING.md
71
93
  - Gemfile
@@ -90,28 +112,26 @@ files:
90
112
  - rintcore.gemspec
91
113
  homepage: https://github.com/KazW/RintCore
92
114
  licenses: []
93
-
94
115
  metadata: {}
95
-
96
116
  post_install_message:
97
117
  rdoc_options: []
98
-
99
- require_paths:
118
+ require_paths:
100
119
  - lib
101
- required_ruby_version: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
105
124
  version: 1.9.1
106
- required_rubygems_version: !ruby/object:Gem::Requirement
107
- requirements:
108
- - *id003
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
109
130
  requirements: []
110
-
111
131
  rubyforge_project:
112
132
  rubygems_version: 2.0.0
113
133
  signing_key:
114
134
  specification_version: 4
115
- summary: A Ruby implementation of PrintCore.
135
+ summary: A Ruby implementation of Printrun's printcore.py and gcoder.py.
116
136
  test_files: []
117
-
137
+ has_rdoc: