mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
fix bugs in signal methods
This commit is contained in:
parent
a06d90d085
commit
4cf4049b40
1 changed files with 9 additions and 8 deletions
|
@ -48,8 +48,9 @@ func (s *Signal) addToSimulationModel() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// adapt length of mapping
|
// adapt length of mapping
|
||||||
m.InputLength = db.Model(m).Where("Direction = ?", "in").Association("InputMapping").Count()
|
var newInputLength = db.Model(m).Where("Direction = ?", "in").Association("InputMapping").Count()
|
||||||
err = m.Update(m)
|
err = db.Model(m).Update("InputLength", newInputLength).Error
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = db.Model(&m).Association("OutputMapping").Append(s).Error
|
err = db.Model(&m).Association("OutputMapping").Append(s).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -57,8 +58,8 @@ func (s *Signal) addToSimulationModel() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// adapt length of mapping
|
// adapt length of mapping
|
||||||
m.OutputLength = db.Model(m).Where("Direction = ?", "out").Association("OutputMapping").Count()
|
var newOutputLength = db.Model(m).Where("Direction = ?", "out").Association("OutputMapping").Count()
|
||||||
err = m.Update(m)
|
err = db.Model(m).Update("OutputLength", newOutputLength).Error
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -94,8 +95,8 @@ func (s *Signal) delete() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce length of mapping by 1
|
// Reduce length of mapping by 1
|
||||||
m.InputLength--
|
var newInputLength = m.InputLength - 1
|
||||||
err = m.Update(m)
|
err = db.Model(m).Update("InputLength", newInputLength).Error
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = db.Model(&m).Association("OutputMapping").Delete(s).Error
|
err = db.Model(&m).Association("OutputMapping").Delete(s).Error
|
||||||
|
@ -104,8 +105,8 @@ func (s *Signal) delete() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce length of mapping by 1
|
// Reduce length of mapping by 1
|
||||||
m.OutputLength--
|
var newOutputLength = m.OutputLength - 1
|
||||||
err = m.Update(m)
|
err = db.Model(m).Update("OutputLength", newOutputLength).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue