Skip to content

Commit 12ebc6c

Browse files
authored
#116 Send loading status while loading simulation. (#118)
1 parent 26069d8 commit 12ebc6c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cse/cse.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ func executeCommand(cmd []string, sim *Simulation, status *structs.SimulationSta
643643
var message = "No feedback implemented for this command"
644644
switch cmd[0] {
645645
case "load":
646+
status.Loading = true
646647
var configDir string
647648
success, message, configDir = initializeSimulation(sim, cmd[1], cmd[2])
648649
if success {
@@ -653,6 +654,7 @@ func executeCommand(cmd []string, sim *Simulation, status *structs.SimulationSta
653654
scenarios := findScenarios(status)
654655
shorty.Scenarios = &scenarios
655656
}
657+
status.Loading = false
656658
case "teardown":
657659
status.Loaded = false
658660
status.Status = "stopped"
@@ -806,6 +808,7 @@ func GetSignalValue(module string, cardinality string, signal string) int {
806808

807809
func GenerateJsonResponse(status *structs.SimulationStatus, sim *Simulation, feedback structs.CommandFeedback, shorty structs.ShortLivedData) structs.JsonResponse {
808810
var response = structs.JsonResponse{
811+
Loading: status.Loading,
809812
Loaded: status.Loaded,
810813
Status: status.Status,
811814
}
@@ -854,7 +857,7 @@ func StateUpdateLoop(state chan structs.JsonResponse, simulationStatus *structs.
854857
func addFmu(execution *C.cse_execution, fmuPath string) (*C.cse_slave, error) {
855858
baseName := filepath.Base(fmuPath)
856859
instanceName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
857-
fmt.Printf("Creating instance %s from %s", instanceName, fmuPath)
860+
fmt.Printf("Creating instance %s from %s\n", instanceName, fmuPath)
858861
localSlave := createLocalSlave(fmuPath, instanceName)
859862
if localSlave == nil {
860863
printLastError()

structs/structs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type ManipulatedVariable struct {
1919
}
2020

2121
type JsonResponse struct {
22+
Loading bool `json:"loading"`
2223
Loaded bool `json:"loaded"`
2324
ExecutionState string `json:"executionState"`
2425
LastErrorCode string `json:"lastErrorCode"`
@@ -72,6 +73,7 @@ type ShortLivedData struct {
7273
}
7374

7475
type SimulationStatus struct {
76+
Loading bool
7577
Loaded bool
7678
ConfigDir string
7779
Module string

0 commit comments

Comments
 (0)