mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
refactoring Model to SimulationModel
This commit is contained in:
parent
a293b1d954
commit
babe1cb308
10 changed files with 184 additions and 191 deletions
|
@ -55,7 +55,7 @@ func VerifyConnection(db *gorm.DB) error {
|
||||||
func DropTables(db *gorm.DB) {
|
func DropTables(db *gorm.DB) {
|
||||||
db.DropTableIfExists(&Simulator{})
|
db.DropTableIfExists(&Simulator{})
|
||||||
//db.DropTableIfExists(&Signal{})
|
//db.DropTableIfExists(&Signal{})
|
||||||
db.DropTableIfExists(&Model{})
|
db.DropTableIfExists(&SimulationModel{})
|
||||||
db.DropTableIfExists(&File{})
|
db.DropTableIfExists(&File{})
|
||||||
db.DropTableIfExists(&Simulation{})
|
db.DropTableIfExists(&Simulation{})
|
||||||
db.DropTableIfExists(&User{})
|
db.DropTableIfExists(&User{})
|
||||||
|
@ -67,7 +67,7 @@ func DropTables(db *gorm.DB) {
|
||||||
func MigrateModels(db *gorm.DB) {
|
func MigrateModels(db *gorm.DB) {
|
||||||
db.AutoMigrate(&Simulator{})
|
db.AutoMigrate(&Simulator{})
|
||||||
//db.AutoMigrate(&Signal{})
|
//db.AutoMigrate(&Signal{})
|
||||||
db.AutoMigrate(&Model{})
|
db.AutoMigrate(&SimulationModel{})
|
||||||
db.AutoMigrate(&File{})
|
db.AutoMigrate(&File{})
|
||||||
db.AutoMigrate(&Simulation{})
|
db.AutoMigrate(&Simulation{})
|
||||||
db.AutoMigrate(&User{})
|
db.AutoMigrate(&User{})
|
||||||
|
@ -110,8 +110,8 @@ func DummyPopulateDB(test_db *gorm.DB) {
|
||||||
//checkErr(test_db.Create(&inSig_A).Error)
|
//checkErr(test_db.Create(&inSig_A).Error)
|
||||||
//checkErr(test_db.Create(&inSig_B).Error)
|
//checkErr(test_db.Create(&inSig_B).Error)
|
||||||
|
|
||||||
mo_A := Model{Name: "Model_A"}
|
mo_A := SimulationModel{Name: "SimulationModel_A"}
|
||||||
mo_B := Model{Name: "Model_B"}
|
mo_B := SimulationModel{Name: "SimulationModel_B"}
|
||||||
checkErr(test_db.Create(&mo_A).Error)
|
checkErr(test_db.Create(&mo_A).Error)
|
||||||
checkErr(test_db.Create(&mo_B).Error)
|
checkErr(test_db.Create(&mo_B).Error)
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ func DummyPopulateDB(test_db *gorm.DB) {
|
||||||
checkErr(test_db.Create(&widg_A).Error)
|
checkErr(test_db.Create(&widg_A).Error)
|
||||||
checkErr(test_db.Create(&widg_B).Error)
|
checkErr(test_db.Create(&widg_B).Error)
|
||||||
|
|
||||||
// Associations betweend models
|
// Associations between models
|
||||||
// For `belongs to` use the model with id=1
|
// For `belongs to` use the model with id=1
|
||||||
// For `has many` use the models with id=1 and id=2
|
// For `has many` use the models with id=1 and id=2
|
||||||
|
|
||||||
|
@ -167,9 +167,9 @@ func DummyPopulateDB(test_db *gorm.DB) {
|
||||||
checkErr(test_db.Model(&simn_B).Association("Users").Append(&usr_A).Error)
|
checkErr(test_db.Model(&simn_B).Association("Users").Append(&usr_A).Error)
|
||||||
checkErr(test_db.Model(&simn_B).Association("Users").Append(&usr_B).Error)
|
checkErr(test_db.Model(&simn_B).Association("Users").Append(&usr_B).Error)
|
||||||
|
|
||||||
// Simulation HM Model
|
// Simulation HM SimulationModels
|
||||||
checkErr(test_db.Model(&simn_A).Association("Models").Append(&mo_A).Error)
|
checkErr(test_db.Model(&simn_A).Association("SimulationModels").Append(&mo_A).Error)
|
||||||
checkErr(test_db.Model(&simn_A).Association("Models").Append(&mo_B).Error)
|
checkErr(test_db.Model(&simn_A).Association("SimulationModels").Append(&mo_B).Error)
|
||||||
|
|
||||||
// Simulation HM Visualizations
|
// Simulation HM Visualizations
|
||||||
checkErr(test_db.Model(&simn_A).Association("Visualizations").Append(&vis_A).Error)
|
checkErr(test_db.Model(&simn_A).Association("Visualizations").Append(&vis_A).Error)
|
||||||
|
@ -179,17 +179,17 @@ func DummyPopulateDB(test_db *gorm.DB) {
|
||||||
checkErr(test_db.Model(&vis_A).Association("Widgets").Append(&widg_A).Error)
|
checkErr(test_db.Model(&vis_A).Association("Widgets").Append(&widg_A).Error)
|
||||||
checkErr(test_db.Model(&vis_A).Association("Widgets").Append(&widg_B).Error)
|
checkErr(test_db.Model(&vis_A).Association("Widgets").Append(&widg_B).Error)
|
||||||
|
|
||||||
// Model HM Signal
|
// SimulationModel HM Signal
|
||||||
//checkErr(test_db.Model(&mo_A).Association("InputMapping").Append(&inSig_A).Error)
|
//checkErr(test_db.Model(&mo_A).Association("InputMapping").Append(&inSig_A).Error)
|
||||||
//checkErr(test_db.Model(&mo_A).Association("InputMapping").Append(&inSig_B).Error)
|
//checkErr(test_db.Model(&mo_A).Association("InputMapping").Append(&inSig_B).Error)
|
||||||
//checkErr(test_db.Model(&mo_A).Association("OutputMapping").Append(&outSig_A).Error)
|
//checkErr(test_db.Model(&mo_A).Association("OutputMapping").Append(&outSig_A).Error)
|
||||||
//checkErr(test_db.Model(&mo_A).Association("OutputMapping").Append(&outSig_B).Error)
|
//checkErr(test_db.Model(&mo_A).Association("OutputMapping").Append(&outSig_B).Error)
|
||||||
|
|
||||||
// Model HM Files
|
// SimulationModel HM Files
|
||||||
checkErr(test_db.Model(&mo_A).Association("Files").Append(&file_A).Error)
|
checkErr(test_db.Model(&mo_A).Association("Files").Append(&file_A).Error)
|
||||||
checkErr(test_db.Model(&mo_A).Association("Files").Append(&file_B).Error)
|
checkErr(test_db.Model(&mo_A).Association("Files").Append(&file_B).Error)
|
||||||
|
|
||||||
// Simulator BT Model
|
// Simulator BT SimulationModel
|
||||||
checkErr(test_db.Model(&mo_A).Association("Simulator").Append(&simr_A).Error)
|
checkErr(test_db.Model(&mo_A).Association("Simulator").Append(&simr_A).Error)
|
||||||
|
|
||||||
// Widget HM Files
|
// Widget HM Files
|
||||||
|
|
|
@ -29,7 +29,7 @@ func TestDummyDBAssociations(t *testing.T) {
|
||||||
|
|
||||||
// Variables for tests
|
// Variables for tests
|
||||||
var simr Simulator
|
var simr Simulator
|
||||||
var mo Model
|
var mo SimulationModel
|
||||||
var file File
|
var file File
|
||||||
var simn Simulation
|
var simn Simulation
|
||||||
var usr User
|
var usr User
|
||||||
|
@ -38,7 +38,7 @@ func TestDummyDBAssociations(t *testing.T) {
|
||||||
var widg Widget
|
var widg Widget
|
||||||
|
|
||||||
//var sigs []Signal
|
//var sigs []Signal
|
||||||
var mos []Model
|
var mos []SimulationModel
|
||||||
var files []File
|
var files []File
|
||||||
var files_sm []File
|
var files_sm []File
|
||||||
var simns []Simulation
|
var simns []Simulation
|
||||||
|
@ -71,10 +71,10 @@ func TestDummyDBAssociations(t *testing.T) {
|
||||||
"Expected to have %v Users. Has %v.", 2, len(usrs))
|
"Expected to have %v Users. Has %v.", 2, len(usrs))
|
||||||
}
|
}
|
||||||
|
|
||||||
a.NoError(db.Model(&simn).Related(&mos, "Models").Error)
|
a.NoError(db.Model(&simn).Related(&mos, "SimulationModels").Error)
|
||||||
if len(mos) != 2 {
|
if len(mos) != 2 {
|
||||||
a.Fail("Simulation Associations",
|
a.Fail("Simulation Associations",
|
||||||
"Expected to have %v Models. Has %v.", 2, len(mos))
|
"Expected to have %v simulation models. Has %v.", 2, len(mos))
|
||||||
}
|
}
|
||||||
|
|
||||||
a.NoError(db.Model(&simn).Related(&viss, "Visualizations").Error)
|
a.NoError(db.Model(&simn).Related(&viss, "Visualizations").Error)
|
||||||
|
@ -83,12 +83,12 @@ func TestDummyDBAssociations(t *testing.T) {
|
||||||
"Expected to have %v Visualizations. Has %v.", 2, len(viss))
|
"Expected to have %v Visualizations. Has %v.", 2, len(viss))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Model
|
// SimulationModel
|
||||||
|
|
||||||
a.NoError(db.Find(&mo, 1).Error, fM("Model"))
|
a.NoError(db.Find(&mo, 1).Error, fM("SimulationModel"))
|
||||||
a.EqualValues("Model_A", mo.Name)
|
a.EqualValues("SimulationModel_A", mo.Name)
|
||||||
|
|
||||||
// Model Associations
|
// SimulationModel Associations
|
||||||
|
|
||||||
a.NoError(db.Model(&mo).Association("Simulator").Find(&simr).Error)
|
a.NoError(db.Model(&mo).Association("Simulator").Find(&simr).Error)
|
||||||
a.EqualValues("Host_A", simr.Host, "Expected Host_A")
|
a.EqualValues("Host_A", simr.Host, "Expected Host_A")
|
||||||
|
@ -101,7 +101,7 @@ func TestDummyDBAssociations(t *testing.T) {
|
||||||
|
|
||||||
a.NoError(db.Model(&mo).Related(&files_sm, "Files").Error)
|
a.NoError(db.Model(&mo).Related(&files_sm, "Files").Error)
|
||||||
if len(files_sm) != 2 {
|
if len(files_sm) != 2 {
|
||||||
a.Fail("Model Associations",
|
a.Fail("SimulationModel Associations",
|
||||||
"Expected to have %v Files. Has %v.", 2, len(files_sm))
|
"Expected to have %v Files. Has %v.", 2, len(files_sm))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,36 +32,35 @@ type Simulation struct {
|
||||||
StartParameters string
|
StartParameters string
|
||||||
// Users that have access to the simulation
|
// Users that have access to the simulation
|
||||||
Users []*User `gorm:"not null;many2many:user_simulations"`
|
Users []*User `gorm:"not null;many2many:user_simulations"`
|
||||||
// Models that belong to the simulation
|
// SimulationModels that belong to the simulation
|
||||||
Models []Model `gorm:"foreignkey:SimulationID"`
|
SimulationModels []SimulationModel `gorm:"foreignkey:SimulationID"`
|
||||||
// Visualizations that belong to the simulation
|
// Visualizations that belong to the simulation
|
||||||
Visualizations []Visualization `gorm:"foreignkey:SimulationID"`
|
Visualizations []Visualization `gorm:"foreignkey:SimulationID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Model data model
|
// SimulationModel data model
|
||||||
// TODO: rename to SimulationModel
|
type SimulationModel struct {
|
||||||
type Model struct {
|
// ID of simulation model
|
||||||
// ID of model
|
|
||||||
ID uint `gorm:"primary_key;auto_increment"`
|
ID uint `gorm:"primary_key;auto_increment"`
|
||||||
// Name of model
|
// Name of simulation model
|
||||||
Name string `gorm:"not null"`
|
Name string `gorm:"not null"`
|
||||||
// Number of output signals
|
// Number of output signals
|
||||||
OutputLength int `gorm:"default:1"`
|
OutputLength int `gorm:"default:1"`
|
||||||
// Number of input signals
|
// Number of input signals
|
||||||
InputLength int `gorm:"default:1"`
|
InputLength int `gorm:"default:1"`
|
||||||
// Start parameters of model as JSON string
|
// Start parameters of simulation model as JSON string
|
||||||
StartParameters string
|
StartParameters string
|
||||||
// ID of simulation to which model belongs
|
// ID of simulation to which simulation model belongs
|
||||||
SimulationID uint
|
SimulationID uint
|
||||||
// Simulator associated with model
|
// Simulator associated with simulation model
|
||||||
Simulator Simulator
|
Simulator Simulator
|
||||||
// ID of simulator associated with model
|
// ID of simulator associated with simulation model
|
||||||
SimulatorID uint
|
SimulatorID uint
|
||||||
// Mapping of output signals of the model, order of signals is important
|
// Mapping of output signals of the simulation model, order of signals is important
|
||||||
OutputMapping []Signal
|
OutputMapping []Signal
|
||||||
// Mapping of input signals of the model, order of signals is important
|
// Mapping of input signals of the simulation model, order of signals is important
|
||||||
InputMapping []Signal
|
InputMapping []Signal
|
||||||
// Files of model (can be CIM and other model file formats)
|
// Files of simulation model (can be CIM and other simulation model file formats)
|
||||||
Files []File `gorm:"foreignkey:ModelID"`
|
Files []File `gorm:"foreignkey:ModelID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,75 +5,75 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserResponse struct {
|
type UserResponse struct {
|
||||||
Username string `json:"Username"`
|
Username string `json:"Username"`
|
||||||
Role string `json:"Role"`
|
Role string `json:"Role"`
|
||||||
Mail string `json:"Mail"`
|
Mail string `json:"Mail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SimulationResponse struct {
|
type SimulationResponse struct {
|
||||||
Name string `json:"Name"`
|
Name string `json:"Name"`
|
||||||
ID uint `json:"SimulationID"`
|
ID uint `json:"SimulationID"`
|
||||||
Running bool `json:"Running"`
|
Running bool `json:"Running"`
|
||||||
StartParams string `json:"Starting Parameters"`
|
StartParams string `json:"Starting Parameters"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModelResponse struct {
|
type SimulationModelResponse struct {
|
||||||
Name string `json:"Name"`
|
Name string `json:"Name"`
|
||||||
OutputLength int `json:"OutputLength"`
|
OutputLength int `json:"OutputLength"`
|
||||||
InputLength int `json:"InputLength"`
|
InputLength int `json:"InputLength"`
|
||||||
SimulationID uint `json:"SimulationID"`
|
SimulationID uint `json:"SimulationID"`
|
||||||
SimulatorID uint `json:"SimulatorID"`
|
SimulatorID uint `json:"SimulatorID"`
|
||||||
StartParams string `json:"StartParams"`
|
StartParams string `json:"StartParams"`
|
||||||
InputMapping []Signal `json:"InputMapping"`
|
InputMapping []Signal `json:"InputMapping"`
|
||||||
OutputMapping []Signal `json:"OutputMapping"`
|
OutputMapping []Signal `json:"OutputMapping"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SimulatorResponse struct {
|
type SimulatorResponse struct {
|
||||||
UUID string `json:"UUID"`
|
UUID string `json:"UUID"`
|
||||||
Host string `json:"Host"`
|
Host string `json:"Host"`
|
||||||
ModelType string `json:"ModelType"`
|
ModelType string `json:"ModelType"`
|
||||||
Uptime int `json:"Uptime"`
|
Uptime int `json:"Uptime"`
|
||||||
State string `json:"State"`
|
State string `json:"State"`
|
||||||
StateUpdateAt time.Time `json:"StateUpdateAt"`
|
StateUpdateAt time.Time `json:"StateUpdateAt"`
|
||||||
Properties string `json:"Properties"`
|
Properties string `json:"Properties"`
|
||||||
RawProperties string `json:"RawProperties"`
|
RawProperties string `json:"RawProperties"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VisualizationResponse struct {
|
type VisualizationResponse struct {
|
||||||
Name string `json:"Name"`
|
Name string `json:"Name"`
|
||||||
Grid int `json:"Grid"`
|
Grid int `json:"Grid"`
|
||||||
SimulationID uint `json:"SimulationID"`
|
SimulationID uint `json:"SimulationID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WidgetResponse struct {
|
type WidgetResponse struct {
|
||||||
Name string `json:"Name"`
|
Name string `json:"Name"`
|
||||||
Type string `json:"Type"`
|
Type string `json:"Type"`
|
||||||
Width uint `json:"Width"`
|
Width uint `json:"Width"`
|
||||||
Height uint `json:"Height"`
|
Height uint `json:"Height"`
|
||||||
MinWidth uint `json:"MinWidth"`
|
MinWidth uint `json:"MinWidth"`
|
||||||
MinHeight uint `json:"MinHeight"`
|
MinHeight uint `json:"MinHeight"`
|
||||||
X int `json:"X"`
|
X int `json:"X"`
|
||||||
Y int `json:"Y"`
|
Y int `json:"Y"`
|
||||||
Z int `json:"Z"`
|
Z int `json:"Z"`
|
||||||
VisualizationID uint `json:"VisualizationID"`
|
VisualizationID uint `json:"VisualizationID"`
|
||||||
IsLocked bool `json:"IsLocked"`
|
IsLocked bool `json:"IsLocked"`
|
||||||
CustomProperties string `json:"CustomProperties"`
|
CustomProperties string `json:"CustomProperties"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileResponse struct {
|
type FileResponse struct {
|
||||||
Name string `json:"Name"`
|
Name string `json:"Name"`
|
||||||
ID uint `json:"FileID"`
|
ID uint `json:"FileID"`
|
||||||
Path string `json:"Path"`
|
Path string `json:"Path"`
|
||||||
Type string `json:"Type"`
|
Type string `json:"Type"`
|
||||||
Size uint `json:"Size"`
|
Size uint `json:"Size"`
|
||||||
H uint `json:"ImageHeight"`
|
H uint `json:"ImageHeight"`
|
||||||
W uint `json:"ImageWidth"`
|
W uint `json:"ImageWidth"`
|
||||||
Date time.Time `json:"Date"`
|
Date time.Time `json:"Date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Response messages
|
// Response messages
|
||||||
|
|
||||||
type ResponseMsg struct{
|
type ResponseMsg struct {
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,4 +92,3 @@ type ResponseMsgSimulations struct {
|
||||||
type ResponseMsgSimulation struct {
|
type ResponseMsgSimulation struct {
|
||||||
Simulation SimulationResponse `json:"simulation"`
|
Simulation SimulationResponse `json:"simulation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ type UserSerializer struct {
|
||||||
User
|
User
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (self *UserSerializer) Response(assoc bool) UserResponse {
|
func (self *UserSerializer) Response(assoc bool) UserResponse {
|
||||||
|
|
||||||
response := UserResponse{
|
response := UserResponse{
|
||||||
|
@ -72,47 +71,45 @@ type SimulationSerializer struct {
|
||||||
Simulation
|
Simulation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (self *SimulationSerializer) Response() SimulationResponse {
|
func (self *SimulationSerializer) Response() SimulationResponse {
|
||||||
response := SimulationResponse{
|
response := SimulationResponse{
|
||||||
Name: self.Name,
|
Name: self.Name,
|
||||||
ID: self.ID,
|
ID: self.ID,
|
||||||
Running: self.Running,
|
Running: self.Running,
|
||||||
StartParams: self.StartParameters,
|
StartParams: self.StartParameters,
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Model/s Serializers
|
// Model/s Serializers
|
||||||
|
|
||||||
type ModelsSerializer struct {
|
type SimulationModelsSerializer struct {
|
||||||
Ctx *gin.Context
|
Ctx *gin.Context
|
||||||
Models []Model
|
SimulationModels []SimulationModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ModelsSerializer) Response() []ModelResponse {
|
func (self *SimulationModelsSerializer) Response() []SimulationModelResponse {
|
||||||
response := []ModelResponse{}
|
response := []SimulationModelResponse{}
|
||||||
for _, model := range self.Models {
|
for _, simulationmodel := range self.SimulationModels {
|
||||||
serializer := ModelSerializer{self.Ctx, model}
|
serializer := SimulationModelSerializer{self.Ctx, simulationmodel}
|
||||||
response = append(response, serializer.Response())
|
response = append(response, serializer.Response())
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModelSerializer struct {
|
type SimulationModelSerializer struct {
|
||||||
Ctx *gin.Context
|
Ctx *gin.Context
|
||||||
Model
|
SimulationModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ModelSerializer) Response() ModelResponse {
|
func (self *SimulationModelSerializer) Response() SimulationModelResponse {
|
||||||
response := ModelResponse{
|
response := SimulationModelResponse{
|
||||||
Name: self.Name,
|
Name: self.Name,
|
||||||
OutputLength: self.OutputLength,
|
OutputLength: self.OutputLength,
|
||||||
InputLength: self.InputLength,
|
InputLength: self.InputLength,
|
||||||
SimulationID: self.SimulationID,
|
SimulationID: self.SimulationID,
|
||||||
SimulatorID: self.SimulatorID,
|
SimulatorID: self.SimulatorID,
|
||||||
StartParams: self.StartParameters,
|
StartParams: self.StartParameters,
|
||||||
//InputMapping
|
//InputMapping
|
||||||
//OutputMapping
|
//OutputMapping
|
||||||
}
|
}
|
||||||
|
@ -122,7 +119,7 @@ func (self *ModelSerializer) Response() ModelResponse {
|
||||||
// Simulator/s Serializers
|
// Simulator/s Serializers
|
||||||
|
|
||||||
type SimulatorsSerializer struct {
|
type SimulatorsSerializer struct {
|
||||||
Ctx *gin.Context
|
Ctx *gin.Context
|
||||||
Simulators []Simulator
|
Simulators []Simulator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,12 +140,12 @@ type SimulatorSerializer struct {
|
||||||
func (self *SimulatorSerializer) Response() SimulatorResponse {
|
func (self *SimulatorSerializer) Response() SimulatorResponse {
|
||||||
|
|
||||||
response := SimulatorResponse{
|
response := SimulatorResponse{
|
||||||
UUID: self.UUID,
|
UUID: self.UUID,
|
||||||
Host: self.Host,
|
Host: self.Host,
|
||||||
ModelType: self.Modeltype,
|
ModelType: self.Modeltype,
|
||||||
Uptime: self.Uptime,
|
Uptime: self.Uptime,
|
||||||
State: self.State,
|
State: self.State,
|
||||||
StateUpdateAt: self.StateUpdateAt,
|
StateUpdateAt: self.StateUpdateAt,
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
@ -156,7 +153,7 @@ func (self *SimulatorSerializer) Response() SimulatorResponse {
|
||||||
// Visualization/s Serializers
|
// Visualization/s Serializers
|
||||||
|
|
||||||
type VisualizationsSerializer struct {
|
type VisualizationsSerializer struct {
|
||||||
Ctx *gin.Context
|
Ctx *gin.Context
|
||||||
Visualizations []Visualization
|
Visualizations []Visualization
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,12 +171,11 @@ type VisualizationSerializer struct {
|
||||||
Visualization
|
Visualization
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (self *VisualizationSerializer) Response() VisualizationResponse {
|
func (self *VisualizationSerializer) Response() VisualizationResponse {
|
||||||
|
|
||||||
response := VisualizationResponse{
|
response := VisualizationResponse{
|
||||||
Name: self.Name,
|
Name: self.Name,
|
||||||
Grid: self.Grid,
|
Grid: self.Grid,
|
||||||
SimulationID: self.SimulationID,
|
SimulationID: self.SimulationID,
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
|
@ -188,7 +184,7 @@ func (self *VisualizationSerializer) Response() VisualizationResponse {
|
||||||
// Widget/s Serializers
|
// Widget/s Serializers
|
||||||
|
|
||||||
type WidgetsSerializer struct {
|
type WidgetsSerializer struct {
|
||||||
Ctx *gin.Context
|
Ctx *gin.Context
|
||||||
Widgets []Widget
|
Widgets []Widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,17 +205,17 @@ type WidgetSerializer struct {
|
||||||
func (self *WidgetSerializer) Response() WidgetResponse {
|
func (self *WidgetSerializer) Response() WidgetResponse {
|
||||||
|
|
||||||
response := WidgetResponse{
|
response := WidgetResponse{
|
||||||
Name: self.Name,
|
Name: self.Name,
|
||||||
Type: self.Type,
|
Type: self.Type,
|
||||||
Width: self.Width,
|
Width: self.Width,
|
||||||
Height: self.Height,
|
Height: self.Height,
|
||||||
MinWidth: self.MinWidth,
|
MinWidth: self.MinWidth,
|
||||||
MinHeight: self.MinHeight,
|
MinHeight: self.MinHeight,
|
||||||
X: self.X,
|
X: self.X,
|
||||||
Y: self.Y,
|
Y: self.Y,
|
||||||
Z: self.Z,
|
Z: self.Z,
|
||||||
VisualizationID: self.VisualizationID,
|
VisualizationID: self.VisualizationID,
|
||||||
IsLocked: self.IsLocked,
|
IsLocked: self.IsLocked,
|
||||||
//CustomProperties
|
//CustomProperties
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
|
@ -246,7 +242,6 @@ type FileSerializerNoAssoc struct {
|
||||||
File
|
File
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (self *FileSerializerNoAssoc) Response() FileResponse {
|
func (self *FileSerializerNoAssoc) Response() FileResponse {
|
||||||
response := FileResponse{
|
response := FileResponse{
|
||||||
Name: self.Name,
|
Name: self.Name,
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/common"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/common"
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/model"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulationmodel"
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/widget"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ func (f *File) register(fileHeader *multipart.FileHeader, objectType string, obj
|
||||||
f.Path = filepath.Join(getFolderName(objectType, objectID), f.Name)
|
f.Path = filepath.Join(getFolderName(objectType, objectID), f.Name)
|
||||||
f.Size = uint(fileHeader.Size)
|
f.Size = uint(fileHeader.Size)
|
||||||
|
|
||||||
var m model.Model
|
var m simulationmodel.SimulationModel
|
||||||
var w widget.Widget
|
var w widget.Widget
|
||||||
var err error
|
var err error
|
||||||
if objectType == "model" {
|
if objectType == "model" {
|
||||||
|
@ -188,7 +188,7 @@ func (f *File) download(c *gin.Context) {
|
||||||
c.File(f.Path)
|
c.File(f.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) addToModel(model model.Model) error {
|
func (f *File) addToModel(model simulationmodel.SimulationModel) error {
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
err := db.Model(&model).Association("Files").Append(f).Error
|
err := db.Model(&model).Association("Files").Append(f).Error
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -78,7 +78,7 @@ func getSimulations(c *gin.Context) {
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Tags simulations
|
// @Tags simulations
|
||||||
// @Param inputModel body common.ModelResponse true "Simulation to be added"
|
// @Param inputSimulation body common.SimulationResponse true "Simulation to be added"
|
||||||
// @Success 200 "OK."
|
// @Success 200 "OK."
|
||||||
// @Failure 401 "Unauthorized Access"
|
// @Failure 401 "Unauthorized Access"
|
||||||
// @Failure 403 "Access forbidden."
|
// @Failure 403 "Access forbidden."
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package model
|
package simulationmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -10,30 +10,30 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterModelEndpoints(r *gin.RouterGroup) {
|
func RegisterModelEndpoints(r *gin.RouterGroup) {
|
||||||
r.GET("/", getModels)
|
r.GET("/", getSimulationModels)
|
||||||
r.POST("/", addModel)
|
r.POST("/", addSimulationModel)
|
||||||
//r.POST("/:modelID", cloneModel)
|
//r.POST("/:modelID", cloneSimulationModel)
|
||||||
r.PUT("/:modelID", updateModel)
|
r.PUT("/:modelID", updateSimulationModel)
|
||||||
r.GET("/:modelID", getModel)
|
r.GET("/:modelID", getSimulationModel)
|
||||||
r.DELETE("/:modelID", deleteModel)
|
r.DELETE("/:modelID", deleteSimulationModel)
|
||||||
r.GET("/:modelID/signals", getSignals)
|
r.GET("/:modelID/signals", getSignals)
|
||||||
r.POST("/:modelID/signals", addSignal)
|
r.POST("/:modelID/signals", addSignal)
|
||||||
r.DELETE("/:modelID/signals", deleteSignals)
|
r.DELETE("/:modelID/signals", deleteSignals)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getModels godoc
|
// getSimulationModels godoc
|
||||||
// @Summary Get all models of simulation
|
// @Summary Get all simulation models of simulation
|
||||||
// @ID getModels
|
// @ID getSimulationModels
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Tags models
|
// @Tags models
|
||||||
// @Success 200 {array} common.ModelResponse "Array of models to which belong to simulation"
|
// @Success 200 {array} common.SimulationModelResponse "Array of models to which belong to simulation"
|
||||||
// @Failure 401 "Unauthorized Access"
|
// @Failure 401 "Unauthorized Access"
|
||||||
// @Failure 403 "Access forbidden."
|
// @Failure 403 "Access forbidden."
|
||||||
// @Failure 404 "Not found"
|
// @Failure 404 "Not found"
|
||||||
// @Failure 500 "Internal server error"
|
// @Failure 500 "Internal server error"
|
||||||
// @Param simulationID query int true "Simulation ID"
|
// @Param simulationID query int true "Simulation ID"
|
||||||
// @Router /models [get]
|
// @Router /models [get]
|
||||||
func getModels(c *gin.Context) {
|
func getSimulationModels(c *gin.Context) {
|
||||||
|
|
||||||
simID, err := common.GetSimulationID(c)
|
simID, err := common.GetSimulationID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -41,7 +41,7 @@ func getModels(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
var models []common.Model
|
var models []common.SimulationModel
|
||||||
|
|
||||||
var sim simulation.Simulation
|
var sim simulation.Simulation
|
||||||
err = sim.ByID(uint(simID))
|
err = sim.ByID(uint(simID))
|
||||||
|
@ -54,33 +54,33 @@ func getModels(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
serializer := common.ModelsSerializer{c, models}
|
serializer := common.SimulationModelsSerializer{c, models}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"models": serializer.Response(),
|
"models": serializer.Response(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// addModel godoc
|
// addSimulationModel godoc
|
||||||
// @Summary Add a model to a simulation
|
// @Summary Add a simulation model to a simulation
|
||||||
// @ID addModel
|
// @ID addSimulationModel
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Tags models
|
// @Tags models
|
||||||
// @Param inputModel body common.ModelResponse true "Model to be added incl. IDs of simulation and simulator"
|
// @Param inputSimulationModel body common.SimulationModelResponse true "Simulation model to be added incl. IDs of simulation and simulator"
|
||||||
// @Success 200 "OK."
|
// @Success 200 "OK."
|
||||||
// @Failure 401 "Unauthorized Access"
|
// @Failure 401 "Unauthorized Access"
|
||||||
// @Failure 403 "Access forbidden."
|
// @Failure 403 "Access forbidden."
|
||||||
// @Failure 404 "Not found"
|
// @Failure 404 "Not found"
|
||||||
// @Failure 500 "Internal server error"
|
// @Failure 500 "Internal server error"
|
||||||
// @Router /models [post]
|
// @Router /models [post]
|
||||||
func addModel(c *gin.Context) {
|
func addSimulationModel(c *gin.Context) {
|
||||||
|
|
||||||
simID, err := common.GetSimulationID(c)
|
simID, err := common.GetSimulationID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var m Model
|
var m SimulationModel
|
||||||
err = c.BindJSON(&m)
|
err = c.BindJSON(&m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errormsg := "Bad request. Error binding form data to JSON: " + err.Error()
|
errormsg := "Bad request. Error binding form data to JSON: " + err.Error()
|
||||||
|
@ -98,7 +98,7 @@ func addModel(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func cloneModel(c *gin.Context) {
|
func cloneSimulationModel(c *gin.Context) {
|
||||||
|
|
||||||
// modelID, err := routes.GetModelID(c)
|
// modelID, err := routes.GetModelID(c)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
|
@ -132,13 +132,13 @@ func cloneModel(c *gin.Context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateModel godoc
|
// updateSimulationModel godoc
|
||||||
// @Summary Update a model
|
// @Summary Update a simulation model
|
||||||
// @ID updateModel
|
// @ID updateSimulationModel
|
||||||
// @Tags models
|
// @Tags models
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param inputModel body common.ModelResponse true "Model to be updated"
|
// @Param inputSimulationModel body common.SimulationModelResponse true "Simulation model to be updated"
|
||||||
// @Success 200 "OK."
|
// @Success 200 "OK."
|
||||||
// @Failure 401 "Unauthorized Access"
|
// @Failure 401 "Unauthorized Access"
|
||||||
// @Failure 403 "Access forbidden."
|
// @Failure 403 "Access forbidden."
|
||||||
|
@ -146,14 +146,14 @@ func cloneModel(c *gin.Context) {
|
||||||
// @Failure 500 "Internal server error"
|
// @Failure 500 "Internal server error"
|
||||||
// @Param modelID path int true "Model ID"
|
// @Param modelID path int true "Model ID"
|
||||||
// @Router /models/{modelID} [put]
|
// @Router /models/{modelID} [put]
|
||||||
func updateModel(c *gin.Context) {
|
func updateSimulationModel(c *gin.Context) {
|
||||||
|
|
||||||
modelID, err := common.GetModelID(c)
|
modelID, err := common.GetModelID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var modifiedModel Model
|
var modifiedModel SimulationModel
|
||||||
err = c.BindJSON(&modifiedModel)
|
err = c.BindJSON(&modifiedModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errormsg := "Bad request. Error binding form data to JSON: " + err.Error()
|
errormsg := "Bad request. Error binding form data to JSON: " + err.Error()
|
||||||
|
@ -163,7 +163,7 @@ func updateModel(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var m Model
|
var m SimulationModel
|
||||||
err = m.ByID(uint(modelID))
|
err = m.ByID(uint(modelID))
|
||||||
if common.ProvideErrorResponse(c, err) {
|
if common.ProvideErrorResponse(c, err) {
|
||||||
return
|
return
|
||||||
|
@ -178,40 +178,40 @@ func updateModel(c *gin.Context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// getModel godoc
|
// getSimulationModel godoc
|
||||||
// @Summary Get a model
|
// @Summary Get a simulation model
|
||||||
// @ID getModel
|
// @ID getSimulationModel
|
||||||
// @Tags models
|
// @Tags models
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {object} common.ModelResponse "Requested model."
|
// @Success 200 {object} common.SimulationModelResponse "Requested simulation model."
|
||||||
// @Failure 401 "Unauthorized Access"
|
// @Failure 401 "Unauthorized Access"
|
||||||
// @Failure 403 "Access forbidden."
|
// @Failure 403 "Access forbidden."
|
||||||
// @Failure 404 "Not found"
|
// @Failure 404 "Not found"
|
||||||
// @Failure 500 "Internal server error"
|
// @Failure 500 "Internal server error"
|
||||||
// @Param modelID path int true "Model ID"
|
// @Param modelID path int true "Model ID"
|
||||||
// @Router /models/{modelID} [get]
|
// @Router /models/{modelID} [get]
|
||||||
func getModel(c *gin.Context) {
|
func getSimulationModel(c *gin.Context) {
|
||||||
|
|
||||||
modelID, err := common.GetModelID(c)
|
modelID, err := common.GetModelID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var m Model
|
var m SimulationModel
|
||||||
err = m.ByID(uint(modelID))
|
err = m.ByID(uint(modelID))
|
||||||
if common.ProvideErrorResponse(c, err) {
|
if common.ProvideErrorResponse(c, err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
serializer := common.ModelSerializer{c, m.Model}
|
serializer := common.SimulationModelSerializer{c, m.SimulationModel}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"model": serializer.Response(),
|
"model": serializer.Response(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteModel godoc
|
// deleteSimulationModel godoc
|
||||||
// @Summary Delete a model
|
// @Summary Delete a simulation model
|
||||||
// @ID deleteModel
|
// @ID deleteSimulationModel
|
||||||
// @Tags models
|
// @Tags models
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 "OK."
|
// @Success 200 "OK."
|
||||||
|
@ -221,7 +221,7 @@ func getModel(c *gin.Context) {
|
||||||
// @Failure 500 "Internal server error"
|
// @Failure 500 "Internal server error"
|
||||||
// @Param modelID path int true "Model ID"
|
// @Param modelID path int true "Model ID"
|
||||||
// @Router /models/{modelID} [delete]
|
// @Router /models/{modelID} [delete]
|
||||||
func deleteModel(c *gin.Context) {
|
func deleteSimulationModel(c *gin.Context) {
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"message": "Not implemented.",
|
"message": "Not implemented.",
|
||||||
|
@ -249,7 +249,7 @@ func addSignal(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var m Model
|
var m SimulationModel
|
||||||
err = m.ByID(uint(modelID))
|
err = m.ByID(uint(modelID))
|
||||||
if common.ProvideErrorResponse(c, err) {
|
if common.ProvideErrorResponse(c, err) {
|
||||||
return
|
return
|
||||||
|
@ -302,7 +302,7 @@ func getSignals(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var m Model
|
var m SimulationModel
|
||||||
err = m.ByID(uint(modelID))
|
err = m.ByID(uint(modelID))
|
||||||
if common.ProvideErrorResponse(c, err) {
|
if common.ProvideErrorResponse(c, err) {
|
||||||
return
|
return
|
||||||
|
@ -348,7 +348,7 @@ func deleteSignals(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var m Model
|
var m SimulationModel
|
||||||
err = m.ByID(uint(modelID))
|
err = m.ByID(uint(modelID))
|
||||||
if common.ProvideErrorResponse(c, err) {
|
if common.ProvideErrorResponse(c, err) {
|
||||||
return
|
return
|
|
@ -1,4 +1,4 @@
|
||||||
package model
|
package simulationmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -8,26 +8,26 @@ import (
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulator"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulator"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Model struct {
|
type SimulationModel struct {
|
||||||
common.Model
|
common.SimulationModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) save() error {
|
func (m *SimulationModel) save() error {
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
err := db.Create(m).Error
|
err := db.Create(m).Error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) ByID(id uint) error {
|
func (m *SimulationModel) ByID(id uint) error {
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
err := db.Find(m, id).Error
|
err := db.Find(m, id).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Model with id=%v does not exist", id)
|
return fmt.Errorf("Simulation Model with id=%v does not exist", id)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) addToSimulation(simID int) error {
|
func (m *SimulationModel) addToSimulation(simID int) error {
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
var sim simulation.Simulation
|
var sim simulation.Simulation
|
||||||
err := sim.ByID(uint(simID))
|
err := sim.ByID(uint(simID))
|
||||||
|
@ -35,34 +35,34 @@ func (m *Model) addToSimulation(simID int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// save model to DB
|
// save simulation model to DB
|
||||||
err = m.save()
|
err = m.save()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// associate simulator with model
|
// associate simulator with simulation model
|
||||||
var simltr simulator.Simulator
|
var simltr simulator.Simulator
|
||||||
err = simltr.ByID(m.SimulatorID)
|
err = simltr.ByID(m.SimulatorID)
|
||||||
err = db.Model(m).Association("Simulator").Append(&simltr).Error
|
err = db.Model(m).Association("Simulator").Append(&simltr).Error
|
||||||
|
|
||||||
// associate model with simulation
|
// associate simulation model with simulation
|
||||||
err = db.Model(&sim).Association("Models").Append(m).Error
|
err = db.Model(&sim).Association("SimulationModels").Append(m).Error
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) update(modifiedModel Model) error {
|
func (m *SimulationModel) update(modifiedSimulationModel SimulationModel) error {
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
err := db.Model(m).Update(modifiedModel).Error
|
err := db.Model(m).Update(modifiedSimulationModel).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.SimulatorID != modifiedModel.SimulatorID {
|
if m.SimulatorID != modifiedSimulationModel.SimulatorID {
|
||||||
// update simulator
|
// update simulator
|
||||||
var s simulator.Simulator
|
var s simulator.Simulator
|
||||||
err = s.ByID(modifiedModel.SimulatorID)
|
err = s.ByID(modifiedSimulationModel.SimulatorID)
|
||||||
|
|
||||||
err = db.Model(m).Association("Simulator").Replace(s).Error
|
err = db.Model(m).Association("Simulator").Replace(s).Error
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ func (m *Model) update(modifiedModel Model) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) updateSignals(signals []common.Signal, direction string) error {
|
func (m *SimulationModel) updateSignals(signals []common.Signal, direction string) error {
|
||||||
|
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
var err error
|
var err error
|
||||||
|
@ -85,7 +85,7 @@ func (m *Model) updateSignals(signals []common.Signal, direction string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) addSignal(signal common.Signal, direction string) error {
|
func (m *SimulationModel) addSignal(signal common.Signal, direction string) error {
|
||||||
|
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
var err error
|
var err error
|
||||||
|
@ -109,7 +109,7 @@ func (m *Model) addSignal(signal common.Signal, direction string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) deleteSignals(direction string) error {
|
func (m *SimulationModel) deleteSignals(direction string) error {
|
||||||
|
|
||||||
db := common.GetDB()
|
db := common.GetDB()
|
||||||
var err error
|
var err error
|
4
start.go
4
start.go
|
@ -8,8 +8,8 @@ import (
|
||||||
|
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/common"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/common"
|
||||||
_ "git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/doc/autoapi" // apidocs folder is generated by Swag CLI, you have to import it
|
_ "git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/doc/autoapi" // apidocs folder is generated by Swag CLI, you have to import it
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/model"
|
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulation"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulation"
|
||||||
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulationmodel"
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulator"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulator"
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/user"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/user"
|
||||||
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/visualization"
|
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/visualization"
|
||||||
|
@ -51,7 +51,7 @@ func main() {
|
||||||
api.Use(user.Authentication(true))
|
api.Use(user.Authentication(true))
|
||||||
|
|
||||||
simulation.RegisterSimulationEndpoints(api.Group("/simulations"))
|
simulation.RegisterSimulationEndpoints(api.Group("/simulations"))
|
||||||
model.RegisterModelEndpoints(api.Group("/models"))
|
simulationmodel.RegisterModelEndpoints(api.Group("/models"))
|
||||||
visualization.RegisterVisualizationEndpoints(api.Group("/visualizations"))
|
visualization.RegisterVisualizationEndpoints(api.Group("/visualizations"))
|
||||||
widget.RegisterWidgetEndpoints(api.Group("/widgets"))
|
widget.RegisterWidgetEndpoints(api.Group("/widgets"))
|
||||||
file.RegisterFileEndpoints(api.Group("/files"))
|
file.RegisterFileEndpoints(api.Group("/files"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue