lib/plc/emulator/emu_plc.rb in ladder_drive-0.5.2 vs lib/plc/emulator/emu_plc.rb in ladder_drive-0.6.0
- old
+ new
@@ -20,18 +20,22 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require 'ladder_drive/plc_device'
require 'yaml'
+require 'plc_plugins'
include LadderDrive
module Plc
module Emulator
+
class EmuPlc
+ include PlcPlugins
+
attr_accessor :program_data
attr_reader :program_pointer
attr_reader :config
attr_reader :device_dict
attr_reader :errors
@@ -58,10 +62,11 @@
eval "@#{k}_devices = []"
end
@lock = Mutex.new
@config = config
reset
+ load_plugins
end
def device_by_name name
@lock.synchronize {
d = device_dict[name]
@@ -118,10 +123,11 @@
sleep 0.1
end
# Save must be executed berofe sync_output, because changed flag was clear after sync_output
save
sync_output
+ exec_plugins
end
def bool
(stack_device.word & 1) != 0 ? true : false
end
@@ -554,11 +560,9 @@
d.bool = !inverse if self.bool unless d.input?
pop_stack
true
end
def rst; set true; end
-
-
end
end
end