Method: CPEE::Controller#initialize
- Defined in:
- lib/cpee/controller.rb
#initialize(id, opts) ⇒ Controller
Returns a new instance of Controller.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cpee/controller.rb', line 53 def initialize(id,opts) @directory = opts[:instances] + "/#{id}/" @id = id @events = {} @votes = {} @votes_results = {} @communication = {} @callbacks = {} @positions = [] @attributes = {} @attributes_helper = AttributesHelper.new @thread = nil @mutex = Mutex.new @opts = opts @properties = Riddl::Utils::Properties::Backend.new( { :inactive => opts[:properties_schema_inactive], :active => opts[:properties_schema_active], :finished => opts[:properties_schema_finished] }, @directory + '/properties.xml', opts[:properties_init] ) @notifications = Riddl::Utils::Notifications::Producer::Backend.new( opts[:topics], @directory + '/notifications/', opts[:notifications_init] ) unless ['stopped','ready','finished','abandoned'].include?(@properties.data.find("string(/p:properties/p:state)")) @properties.modify do |doc| doc.find("/p:properties/p:state").first.text = 'stopped' end end @uuid = sync_uuid! if @properties.data.find("string(/p:properties/p:state)") == "finished" @instance = nil else @instance = EmptyWorkflow.new(self) @notifications.subscriptions.keys.each do |key| self.unserialize_notifications!(:cre,key) end unserialize_handlerwrapper! unserialize_dataelements! unserialize_endpoints! unserialize_dsl! unserialize_positions! unserialize_attributes! end end |