350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
# File 'lib/openc3/models/interface_model.rb', line 350
def map_target(target_name, cmd_only: false, tlm_only: false, unmap_old: true)
if cmd_only and tlm_only
cmd_only = false
tlm_only = false
end
target_name = target_name.to_s.upcase
ensure_target_exists(target_name)
if unmap_old
all_interfaces = InterfaceModel.all(scope: scope)
old_interface = nil
all_interfaces.each do |old_interface_name, old_interface_details|
if old_interface_details['target_names'].include?(target_name)
old_interface = InterfaceModel.from_json(old_interface_details, scope: scope)
old_interface.unmap_target(target_name, cmd_only: cmd_only, tlm_only: tlm_only) if old_interface
end
end
end
@target_names << target_name unless @target_names.include?(target_name)
@cmd_target_names << target_name unless @cmd_target_names.include?(target_name) or tlm_only
@tlm_target_names << target_name unless @tlm_target_names.include?(target_name) or cmd_only
update()
type = self.class._get_type
microservice_name = "#{@scope}__#{type}__#{@name}"
microservice = MicroserviceModel.get_model(name: microservice_name, scope: scope)
microservice.target_names << target_name unless microservice.target_names.include?(target_name)
microservice.update
end
|