Class: OpenC3::PacketBase

Inherits:
Object show all
Defined in:
lib/openc3/microservices/trigger_group_microservice.rb

Overview

Stored in the TriggerGroupShare this should be a thread safe hash that triggers will be added, updated, and removed from

Instance Method Summary collapse

Constructor Details

#initialize(scope:) ⇒ PacketBase

Returns a new instance of PacketBase.



39
40
41
42
43
# File 'lib/openc3/microservices/trigger_group_microservice.rb', line 39

def initialize(scope:)
  @scope = scope
  @mutex = Mutex.new
  @packets = Hash.new
end

Instance Method Details

#add(topic:, packet:) ⇒ Object



59
60
61
62
63
# File 'lib/openc3/microservices/trigger_group_microservice.rb', line 59

def add(topic:, packet:)
  @mutex.synchronize do
    @packets[topic] = packet
  end
end

#get(topic:) ⇒ Object



53
54
55
56
57
# File 'lib/openc3/microservices/trigger_group_microservice.rb', line 53

def get(topic:)
  @mutex.synchronize do
    return Marshal.load( Marshal.dump(@packets[topic]) )
  end
end

#packet(target:, packet:) ⇒ Object

“#@scope__DECOM__#{@target}__#@packet”


46
47
48
49
50
51
# File 'lib/openc3/microservices/trigger_group_microservice.rb', line 46

def packet(target:, packet:)
  topic = "#{@scope}__DECOM__{#{target}}__#{packet}"
  @mutex.synchronize do
    return Marshal.load( Marshal.dump(@packets[topic]) )
  end
end

#remove(topic:) ⇒ Object



65
66
67
68
69
# File 'lib/openc3/microservices/trigger_group_microservice.rb', line 65

def remove(topic:)
  @mutex.synchronize do
    @packets.delete(topic)
  end
end