VOL-1358 BBSim - Improve the mediator component
This update is for triggering the test activation per-ONU.
Each OLT/ONU instance's state update is notified to the mediator.
Change-Id: Ia702c0081720d4f1cee10929077b97cc0661c375
diff --git a/device/device_onu.go b/device/device_onu.go
index 24f2cbf..c1a7aad 100644
--- a/device/device_onu.go
+++ b/device/device_onu.go
@@ -25,15 +25,13 @@
log "github.com/sirupsen/logrus"
)
-type onuState int
-
const (
- ONU_PRE_ACTIVATED onuState = iota
- ONU_ACTIVATED
+ ONU_PREACTIVATED DeviceState = iota
+ ONU_ACTIVE
)
type Onu struct {
- InternalState *onuState
+ InternalState DeviceState
OltID uint32
IntfID uint32
OperState string
@@ -51,8 +49,7 @@
onus := []*Onu{}
for i := 0; i < int(nonus); i++ {
onu := Onu{}
- onu.InternalState = new(onuState)
- *onu.InternalState = ONU_PRE_ACTIVATED
+ onu.InternalState = ONU_PREACTIVATED
onu.mu = &sync.Mutex{}
onu.IntfID = intfid
onu.OltID = oltid
@@ -65,9 +62,9 @@
return onus
}
-func (onu *Onu) InitializeStatus() {
+func (onu *Onu) Initialize() {
onu.OperState = "up"
- *onu.InternalState = ONU_PRE_ACTIVATED
+ onu.InternalState = ONU_PREACTIVATED
}
func ValidateONU(targetonu openolt.Onu, regonus map[uint32][]*Onu) bool {
@@ -95,14 +92,18 @@
}
}
-func (onu *Onu) UpdateIntStatus(intstatus onuState) {
+func (onu *Onu) UpdateIntState(intstate DeviceState) {
onu.mu.Lock()
defer onu.mu.Unlock()
- *onu.InternalState = intstatus
+ onu.InternalState = intstate
}
-func (onu *Onu) GetIntStatus() onuState {
+func (onu *Onu) GetDevkey () Devkey {
+ return Devkey{ID: onu.OnuID, Intfid:onu.IntfID}
+}
+
+func (onu *Onu) GetIntState() DeviceState {
onu.mu.Lock()
defer onu.mu.Unlock()
- return *onu.InternalState
+ return onu.InternalState
}