Skip to content

Commit

Permalink
#116 Send loading status while loading simulation. (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
eidekrist authored Oct 29, 2019
1 parent 26069d8 commit 12ebc6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cse/cse.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ func executeCommand(cmd []string, sim *Simulation, status *structs.SimulationSta
var message = "No feedback implemented for this command"
switch cmd[0] {
case "load":
status.Loading = true
var configDir string
success, message, configDir = initializeSimulation(sim, cmd[1], cmd[2])
if success {
Expand All @@ -653,6 +654,7 @@ func executeCommand(cmd []string, sim *Simulation, status *structs.SimulationSta
scenarios := findScenarios(status)
shorty.Scenarios = &scenarios
}
status.Loading = false
case "teardown":
status.Loaded = false
status.Status = "stopped"
Expand Down Expand Up @@ -806,6 +808,7 @@ func GetSignalValue(module string, cardinality string, signal string) int {

func GenerateJsonResponse(status *structs.SimulationStatus, sim *Simulation, feedback structs.CommandFeedback, shorty structs.ShortLivedData) structs.JsonResponse {
var response = structs.JsonResponse{
Loading: status.Loading,
Loaded: status.Loaded,
Status: status.Status,
}
Expand Down Expand Up @@ -854,7 +857,7 @@ func StateUpdateLoop(state chan structs.JsonResponse, simulationStatus *structs.
func addFmu(execution *C.cse_execution, fmuPath string) (*C.cse_slave, error) {
baseName := filepath.Base(fmuPath)
instanceName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
fmt.Printf("Creating instance %s from %s", instanceName, fmuPath)
fmt.Printf("Creating instance %s from %s\n", instanceName, fmuPath)
localSlave := createLocalSlave(fmuPath, instanceName)
if localSlave == nil {
printLastError()
Expand Down
2 changes: 2 additions & 0 deletions structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ManipulatedVariable struct {
}

type JsonResponse struct {
Loading bool `json:"loading"`
Loaded bool `json:"loaded"`
ExecutionState string `json:"executionState"`
LastErrorCode string `json:"lastErrorCode"`
Expand Down Expand Up @@ -72,6 +73,7 @@ type ShortLivedData struct {
}

type SimulationStatus struct {
Loading bool
Loaded bool
ConfigDir string
Module string
Expand Down

0 comments on commit 12ebc6c

Please sign in to comment.