423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
# File 'lib/openc3/models/interface_model.rb', line 423
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
|