Added call to resource update in arena update

graph-rework
noah metz 2023-06-03 01:54:14 -06:00
parent f838f53dda
commit f6a36f9028
3 changed files with 8 additions and 6 deletions

@ -356,7 +356,7 @@ func NewEventQueue(name string, description string, required_resources []Resourc
err := LockResources(event) err := LockResources(event)
// start in new goroutine // start in new goroutine
if err != nil { if err != nil {
log.Printf("Failed to lock %s: %s", event.Name(), err) //log.Printf("Failed to lock %s: %s", event.Name(), err)
} else { } else {
info.state = "running" info.state = "running"
log.Printf("EVENT_START: %s", event.Name()) log.Printf("EVENT_START: %s", event.Name())

@ -96,6 +96,7 @@ func (arena * Arena) lock(event Event) error {
func (arena * Arena) update(signal GraphSignal) { func (arena * Arena) update(signal GraphSignal) {
log.Printf("ARENA_UPDATE: %s", arena.Name()) log.Printf("ARENA_UPDATE: %s", arena.Name())
arena.BaseResource.update(signal)
arena.signal <- signal arena.signal <- signal
} }

@ -150,14 +150,15 @@ func TestNewMatch(t *testing.T) {
go func(match_c chan GraphSignal) { go func(match_c chan GraphSignal) {
(*graph_tester)(t).CheckForValue(match_c, "no update to match after starting 1") (*graph_tester)(t).CheckForValue(match_c, "no update to match after starting 1")
(*graph_tester)(t).CheckForNone(match_c, "update to match after starting 2") (*graph_tester)(t).CheckForValue(match_c, "no update to match after starting 2")
SendUpdate(match, NewSignal(nil, "queue_autonomous")) (*graph_tester)(t).CheckForNone(match_c, "update to match after starting 3")
SendUpdate(arena, NewSignal(nil, "queue_autonomous"))
(*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing autonomous 1") (*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing autonomous 1")
(*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing autonomous 2") (*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing autonomous 2")
(*graph_tester)(t).CheckForNone(match_c, "update to match after queueing autonomous 3") (*graph_tester)(t).CheckForNone(match_c, "update to match after queueing autonomous 3")
auton_signal := NewSignal(nil, "start_autonomous") auton_signal := NewSignal(nil, "start_autonomous")
auton_signal.time = time.Now() auton_signal.time = time.Now()
SendUpdate(match, auton_signal) SendUpdate(arena, auton_signal)
(*graph_tester)(t).CheckForValue(match_c, "no update to match after starting autonomous 1") (*graph_tester)(t).CheckForValue(match_c, "no update to match after starting autonomous 1")
(*graph_tester)(t).CheckForValue(match_c, "no update to match after starting autonomous 2") (*graph_tester)(t).CheckForValue(match_c, "no update to match after starting autonomous 2")
(*graph_tester)(t).CheckForNone(match_c, "update to match after starting autonomous 3") (*graph_tester)(t).CheckForNone(match_c, "update to match after starting autonomous 3")
@ -165,13 +166,13 @@ func TestNewMatch(t *testing.T) {
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 100)
(*graph_tester)(t).CheckForValue(match_c, "no update to match after ending autonomous 1") (*graph_tester)(t).CheckForValue(match_c, "no update to match after ending autonomous 1")
(*graph_tester)(t).CheckForNone(match_c, "update to match after ending autonomous 2") (*graph_tester)(t).CheckForNone(match_c, "update to match after ending autonomous 2")
SendUpdate(match, NewSignal(nil, "queue_driver")) SendUpdate(arena, NewSignal(nil, "queue_driver"))
(*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing driver 1") (*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing driver 1")
(*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing driver 2") (*graph_tester)(t).CheckForValue(match_c, "no update to match after queueing driver 2")
(*graph_tester)(t).CheckForNone(match_c, "update to match after queueing driver 3") (*graph_tester)(t).CheckForNone(match_c, "update to match after queueing driver 3")
driver_signal := NewSignal(nil, "start_driver") driver_signal := NewSignal(nil, "start_driver")
driver_signal.time = time.Now() driver_signal.time = time.Now()
SendUpdate(match, driver_signal) SendUpdate(arena, driver_signal)
(*graph_tester)(t).CheckForValue(match_c, "no update to match after starting driver 1") (*graph_tester)(t).CheckForValue(match_c, "no update to match after starting driver 1")
(*graph_tester)(t).CheckForValue(match_c, "no update to match after starting driver 2") (*graph_tester)(t).CheckForValue(match_c, "no update to match after starting driver 2")
(*graph_tester)(t).CheckForNone(match_c, "update to match after starting driver 3") (*graph_tester)(t).CheckForNone(match_c, "update to match after starting driver 3")