From 601ec9c9fa88afd86681e40e9eda6731235c7d8f Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 3 Aug 2012 19:55:28 +0200 Subject: [PATCH] oml: Move the init into a new class/method. The goal is to a list of statements for the entire init instead of just being state driven. I will also experiment with continuations and then take this experience to the call control code of the MSC. --- fakebts/AllCode.st | 3 ++- fakebts/BTS.st | 41 ++++++++++++++++++++++++------ fakebts/OML.st | 8 +++++- fakebts/OMLInit.st | 63 ++++++++++++++++++++++++++++++++++++++++++++++ fakebts/OMLMsg.st | 5 ++++ 5 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 fakebts/OMLInit.st diff --git a/fakebts/AllCode.st b/fakebts/AllCode.st index 41b552e..26c7063 100644 --- a/fakebts/AllCode.st +++ b/fakebts/AllCode.st @@ -4,5 +4,6 @@ Eval [ fileIn: 'BTSConnection.st'; fileIn: 'TLV.st'; fileIn: 'OMLMsg.st'; - fileIn: 'OML.st'. + fileIn: 'OML.st'; + fileIn: 'OMLInit.st'. ] diff --git a/fakebts/BTS.st b/fakebts/BTS.st index 6d97a71..ed32158 100644 --- a/fakebts/BTS.st +++ b/fakebts/BTS.st @@ -20,7 +20,7 @@ simulating failure condition..." Object subclass: BTS [ - | site_mgr oml rsl | + | site_mgr oml rsl oml_queue oml_init | @@ -32,15 +32,21 @@ Object subclass: BTS [ rsl := nil. oml := BTSOmlConnection new onData: [:each | self handleOml: each]; - onStop: [self stoppedOml]; + onStop: [self omlStopped]; onConnect: [self omlConnected]; yourself. "Make sure oml is fully assigned" + oml_queue := SharedQueue new. oml connect: anAddress ] - stoppedOml [ + siteManager [ + + ^ site_mgr + ] + + omlStopped [ Transcript nextPutAll: 'OML Connection gone.'; nl. ] @@ -49,10 +55,11 @@ Object subclass: BTS [ Transcript nextPutAll: 'OML Connected'; nl. - site_mgr := SiteManagerOML new - onData: [:each | self sendOML: each]; - start; - yourself. + site_mgr := SiteManagerOML new. + + "Start the OML init now in a new thread" + oml_init := OMLBTSInit initWith: self. + [[oml_init run ] ensure: [Transcript nextPutAll: 'OML-Init exited'; nl]] fork. ] stop [ @@ -61,6 +68,7 @@ Object subclass: BTS [ rsl isNil ifFalse: [rsl stop. rsl := nil]. oml isNil ifFalse: [oml stop. oml := nil]. + oml_init isNil ifFalse: [oml_queue nextPut: nil. oml_init := nil]. ] sendOML: aMsg [ @@ -68,9 +76,26 @@ Object subclass: BTS [ oml send: aMsg. ] + waitForOMLMsg [ + + "TODO: do something funny with continuations" + ^ oml_queue next + ] + handleOml: aMsg [ + | oml | Transcript nextPutAll: 'Got OML'; nl. - aMsg asByteArray printNl. + [ + oml := OMLMessageBase parse: aMsg asByteArray readStream. + oml_queue nextPut: oml. + ] on: Exception do: [:e | + Transcript nextPutAll: 'OML Parsing failed with'; nl. + e inspect. + Transcript + nextPutAll: 'With data: '; + nextPutAll: aMsg asByteArray printString; + nl. + ] ] ] diff --git a/fakebts/OML.st b/fakebts/OML.st index e367cbd..291fe95 100644 --- a/fakebts/OML.st +++ b/fakebts/OML.st @@ -111,7 +111,7 @@ Object subclass: OMLManagerBase [ ] OMLManagerBase subclass: SiteManagerOML [ - | bts onData swActivated | + | bts onData swActivated swLoaded | @@ -175,6 +175,7 @@ OMLManagerBase subclass: SiteManagerOML [ | fom | + swLoaded := false. swActivated := false. self basicStart. self bts start. @@ -198,6 +199,11 @@ OMLManagerBase subclass: SiteManagerOML [ self forwardData: fom toMessage. ] + loadSoftware: aSWConfiguration [ + + swLoaded := true. + ] + siteManager [ ^ self diff --git a/fakebts/OMLInit.st b/fakebts/OMLInit.st new file mode 100644 index 0000000..0002954 --- /dev/null +++ b/fakebts/OMLInit.st @@ -0,0 +1,63 @@ +" + (C) 2012 by Holger Hans Peter Freyther + All Rights Reserved + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +" + +"Attempt to have the OMLinit as a imperative routine" + +Object subclass: OMLBTSInit [ + | sm bts | + + + + OMLBTSInit class >> initWith: aBts [ + + ^ self new + bts: aBts; + yourself + ] + + bts: aBts [ + + bts := aBts. + sm := aBts siteManager + onData: [:each | self forwardOML: each]; + yourself. + ] + + forwardOML: aMsg [ + "It could be filtered here" + bts sendOML: aMsg + ] + + run [ + | msg | + "1. Initialize the SM" + sm start. + + "2. Activate the software" + msg := bts waitForOMLMsg. + msg class = FOMMessage + ifFalse: [self error: 'Failed to get a Formatted O&M message']. + msg omDataField class = OMLSWActivateRequestAck + ifFalse: [self error: 'Failed to get the SW Activate Request ACK']. + Transcript nextPutAll: 'We were asked to activate something'; nl. + (Delay forSeconds: 1) wait. + sm loadSoftware: msg omDataField swConfiguration. + ] +] diff --git a/fakebts/OMLMsg.st b/fakebts/OMLMsg.st index 426181f..56bfaaa 100644 --- a/fakebts/OMLMsg.st +++ b/fakebts/OMLMsg.st @@ -801,6 +801,11 @@ OMLDataField subclass: OMLSWActivateRequest [ sw_config := aSWConfig ] + + swConfiguration [ + + ^ sw_config + ] ] OMLSWActivateRequest subclass: OMLSWActivateRequestAck [