@@ -171,3 +171,43 @@ func TestNewResource(t *testing.T) {
171171 sys .UAssets [ua .GetName ()] = & ua
172172 }
173173}
174+
175+ func TestfeedbackLoop () {
176+ ctx , cancel := context .WithCancel (context .Background ())
177+ defer cancel ()
178+
179+ // instantiate the System
180+ sys := components .NewSystem ("testsys" , ctx )
181+
182+ // Instatiate the Capusle
183+ sys .Husk = & components.Husk {
184+ Description : " is a controller for smart thermostats connected with a RaspBee II" ,
185+ Certificate : "ABCD" ,
186+ Details : map [string ][]string {"Developer" : {"Arrowhead" }},
187+ ProtoPort : map [string ]int {"https" : 0 , "http" : 8870 , "coap" : 0 },
188+ InfoLink : "https://github.com/sdoque/systems/tree/master/ZigBeeValve" ,
189+ }
190+
191+ // instantiate a template unit asset
192+ assetTemplate := initTemplate ()
193+ assetName := assetTemplate .GetName ()
194+ sys .UAssets [assetName ] = & assetTemplate
195+
196+ // Configure the system
197+ rawResources , servsTemp , err := usecases .Configure (& sys )
198+ if err != nil {
199+ log .Fatalf ("Configuration error: %v\n " , err )
200+ }
201+ sys .UAssets = make (map [string ]* components.UnitAsset ) // clear the unit asset map (from the template)
202+ for _ , raw := range rawResources {
203+ var uac UnitAsset
204+ if err := json .Unmarshal (raw , & uac ); err != nil {
205+ log .Fatalf ("Resource configuration error: %+v\n " , err )
206+ }
207+ ua , startup := newResource (uac , & sys , servsTemp )
208+ startup ()
209+ sys .UAssets [ua .GetName ()] = & ua
210+ }
211+
212+ // TODO: Test feedbackloop and processfeedbackloop
213+ }
0 commit comments