Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trend spec for each individual trend #71

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cse/cse.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,15 @@ func executeCommand(cmd []string, sim *Simulation, status *structs.SimulationSta
case "setlabel":
success, message = setTrendLabel(status, cmd[1], cmd[2])
case "trend-zoom":
status.TrendSpec = structs.TrendSpec{Auto: false, Begin: parseFloat(cmd[1]), End: parseFloat(cmd[2])}
idx, _ := strconv.Atoi(cmd[1])
status.Trends[idx].Spec = structs.TrendSpec{Auto: false, Begin: parseFloat(cmd[2]), End: parseFloat(cmd[3])}
success = true
message = strCat("Trending values from ", cmd[1], " to ", cmd[2])
message = strCat("Plotting values from ", cmd[2], " to ", cmd[3])
case "trend-zoom-reset":
status.TrendSpec = structs.TrendSpec{Auto: true, Range: parseFloat(cmd[1])}
idx, _ := strconv.Atoi(cmd[1])
status.Trends[idx].Spec = structs.TrendSpec{Auto: true, Range: parseFloat(cmd[2])}
success = true
message = strCat("Trending last ", cmd[1], " seconds")
message = strCat("Plotting last ", cmd[2], " seconds")
case "set-value":
success, message = setVariableValue(sim, cmd[1], cmd[2], cmd[3], cmd[4], cmd[5])
case "reset-value":
Expand Down
9 changes: 6 additions & 3 deletions cse/trending.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func addNewTrend(status *structs.SimulationStatus, plotType string, label string
Id: id,
PlotType: plotType,
Label: label,
TrendSignals: []structs.TrendSignal{}})
TrendSignals: []structs.TrendSignal{},
Spec: structs.TrendSpec{
Auto: true,
Range: 10.0}})
return true, "Added new trend"
}

Expand Down Expand Up @@ -110,7 +113,7 @@ func TrendLoop(sim *Simulation, status *structs.SimulationStatus) {
var signal = &trend.TrendSignals[i]
switch signal.Type {
case "Real":
observerGetRealSamples(sim.TrendObserver, signal, status.TrendSpec)
observerGetRealSamples(sim.TrendObserver, signal, trend.Spec)
}
}
}
Expand All @@ -122,7 +125,7 @@ func TrendLoop(sim *Simulation, status *structs.SimulationStatus) {
var signal1 = &trend.TrendSignals[j]
var signal2 = &trend.TrendSignals[j+1]
if (signal1.Type == "Real" && signal2.Type == "Real") {
observerGetRealSynchronizedSamples(sim.TrendObserver, signal1, signal2, status.TrendSpec)
observerGetRealSynchronizedSamples(sim.TrendObserver, signal1, signal2, trend.Spec)
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ func main() {
Loaded: false,
Status: "stopped",
Trends: []structs.Trend{},
TrendSpec: structs.TrendSpec{
Auto: true,
Range: 10.0},
}

// Passing the channel to the go routine
Expand Down
10 changes: 5 additions & 5 deletions structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ type Trend struct {
PlotType string `json:"plot-type"`
Label string `json:"label"`
TrendSignals []TrendSignal `json:"trend-values"`
Spec TrendSpec `json:"spec"`
}

type TrendSpec struct {
Begin float64
End float64
Range float64
Auto bool
Begin float64 `json:"begin"`
End float64 `json:"end"`
Range float64 `json:"range"`
Auto bool `json:"auto"`
}

type ShortLivedData struct {
Expand All @@ -65,7 +66,6 @@ type SimulationStatus struct {
Module string
SignalSubscriptions []Variable
Trends []Trend
TrendSpec TrendSpec
Status string
CurrentScenario string
}
Expand Down