@@ -93,7 +93,9 @@ app.controller('configFormController', function($scope, $rootScope, $http, $inte
93
93
if ( $scope . configData . trial . runtime . cameraState == 'armed' || $scope . configData . trial . runtime . cameraState == 'armedrecording' ) {
94
94
//20180718, get this working
95
95
//console.log('CallParentMethod_SetConfigData() is calling $route.reload()')
96
- console . log ( '$rootScope.$on("CallParentMethod_SetConfigData" is calling $route.reload' )
96
+
97
+ // this gets called at an interval (very expensive for Pi to be serving this)
98
+ //console.log('$rootScope.$on("CallParentMethod_SetConfigData" is calling $route.reload')
97
99
$route . reload ( ) ;
98
100
}
99
101
@@ -224,7 +226,9 @@ app.controller('configFormController', function($scope, $rootScope, $http, $inte
224
226
} ) ; // configFormController
225
227
226
228
229
+
227
230
//////////////////////////////////////////////////////////////////////////////
231
+ // controller for motor
228
232
app . controller ( 'arduinoFormController' , function ( $scope , $rootScope , $http , statusFactory ) {
229
233
230
234
// take current params and submit
@@ -244,13 +248,78 @@ app.controller('arduinoFormController', function($scope, $rootScope, $http, stat
244
248
} ) ;
245
249
} ;
246
250
247
- //rebuild plotly but do not submit
251
+ // 20181220
252
+ //$scope.$on('someEvent', function(event, args) {
253
+ /*
254
+ $scope.$on('someEvent', function(event, data) {
255
+ //args is secondsElapsedStr
256
+ console.log('arduinoFormController received someEvent')
257
+ //$scope.refreshPlotly(args);
258
+ });
259
+ */
260
+
261
+ //
262
+ //
263
+ //
264
+ //
265
+ //
266
+ //
267
+ //
268
+ //
269
+ // THIS IS FUCKING IMPOSSIBLE TO GET WORKING
270
+ // I CAN NOT DEAL WITH THESE JAVASCRIPT FRAMEWORKS !!!!!!!!!!!!!!!!!
271
+ // THEY MAKE MY CODING STALL FOR DAYS AND WEEKS
272
+ // COME ON GOOD AND FACEBOOK, THIS IS FUCKING BULLSHIT
273
+ //
274
+ //
275
+ //
276
+ //
277
+ //
278
+ //
279
+ //
280
+ //
281
+ //
282
+
283
+ /*
284
+ $rootScope.$on("rootEvent", function(event, thisConfig) {
285
+ console.log('arduinoFormController received rootEvent')
286
+ })
287
+ $scope.$on("rootEvent", function(event, thisConfig) {
288
+ console.log('arduinoFormController received rootEvent')
289
+ })
290
+ */
291
+
292
+ $scope . $on ( 'rootEvent2' , function ( event , secondsElapsedStr ) {
293
+ console . log ( 'I am from motor controller' , secondsElapsedStr ) ;
294
+ var msElapsed = parseFloat ( secondsElapsedStr ) * 1000 ;
295
+ Plotly . restyle ( 'test_plotly' , 'x' , [ [ msElapsed , msElapsed ] ] ) ;
296
+ } ) ;
297
+
298
+ /*
299
+ $scope.$on('rootEvent', function(event, data){
300
+ console.log('arduinoFormController received rootEvent')
301
+ })
302
+ $rootScope.$on('rootEvent', function(event, data){
303
+ console.log('arduinoFormController received rootEvent')
304
+ })
305
+ */
306
+
307
+ //rebuild plotly but do not submit
248
308
$scope . motorParamChange = function ( ) {
249
309
// if form fields don't pass validation, they will be 'undefined'
250
310
console . log ( 'motorParamChange()' , $scope . data )
251
311
buildPlotly ( $scope . data )
252
312
}
253
313
314
+ // respond to new secondsElapsedStr
315
+ /*
316
+ $scope.updateRuntime - function() {
317
+ // Plotly.react(gd, data, layout, config)
318
+ //buildPlotly($scope.data) //$scope.data is motorParams
319
+ $scope.refreshPlotly($scope.status)
320
+ }
321
+ */
322
+
254
323
var myPromise = statusFactory . getStatus ( )
255
324
myPromise . then ( function ( result ) {
256
325
var status = result
@@ -268,6 +337,11 @@ app.controller('arduinoFormController', function($scope, $rootScope, $http, stat
268
337
269
338
} ) ; // mypromise.then
270
339
340
+ // respond to new secondsElapsedStr
341
+ $scope . refreshPlotly = function ( status ) {
342
+ console . log ( 'refreshPlotly()' )
343
+ }
344
+
271
345
var buildPlotly = function ( motorParams ) {
272
346
var trialMS = motorParams . motorNumEpochs * motorParams . motorRepeatDuration
273
347
//console.log('buildPlotly() trialMS:', trialMS)
@@ -292,8 +366,8 @@ app.controller('arduinoFormController', function($scope, $rootScope, $http, stat
292
366
293
367
var data = [
294
368
{
295
- x : [ ] ,
296
- y : [ ] ,
369
+ x : [ 100 , 100 ] ,
370
+ y : [ 0 , 1 ] ,
297
371
type : 'scatter'
298
372
}
299
373
] ;
@@ -316,6 +390,7 @@ app.controller('arduinoFormController', function($scope, $rootScope, $http, stat
316
390
'color' : lineColor ,
317
391
} ,
318
392
'fillcolor' : lineColor ,
393
+ opacity : 0.5 ,
319
394
} ;
320
395
shapeList . push ( thisRect )
321
396
}
@@ -569,6 +644,7 @@ app.controller('treadmill', function($scope, $rootScope, $window, $http, $locati
569
644
570
645
///////////////////////////////////////////////////////////////////////////
571
646
// counter to display elapsed recording time rather than hitting REST with http.get
647
+ // this is used while we are acquiring data, VERY IMPORTANT
572
648
var defaultInterval = 800 ; // 800
573
649
var counter = 0 ;
574
650
$scope . myIntervalFunction = function ( ) {
@@ -578,6 +654,51 @@ app.controller('treadmill', function($scope, $rootScope, $window, $http, $locati
578
654
counter += 0.4
579
655
counter = Math . round ( counter * 100 ) / 100
580
656
$scope . status . trial . runtime . secondsElapsedStr = counter
657
+
658
+ //
659
+ //
660
+ //
661
+ //
662
+ //
663
+ //
664
+ //
665
+ //
666
+ // THIS IS FUCKING IMPOSSIBLE TO GET WORKING
667
+ // I CAN NOT DEAL WITH THESE JAVASCRIPT FRAMEWORKS !!!!!!!!!!!!!!!!!
668
+ // THEY MAKE MY CODING STALL FOR DAYS AND WEEKS
669
+ // COME ON GOOD AND FACEBOOK, THIS IS FUCKING BULLSHIT
670
+ //
671
+ //
672
+ //
673
+ //
674
+ //
675
+ //
676
+ //
677
+ //
678
+ //
679
+
680
+ // see: https://stackoverflow.com/questions/9293423/can-one-angularjs-controller-call-another
681
+ // 20181220, update plot of motor !!!
682
+ //$scope.refreshPlotly($scope.status)
683
+
684
+ // emit an update (for motor controller)
685
+ //$rootScope.$broadcast('someEvent', $scope.status.trial.runtime.secondsElapsedStr);
686
+
687
+ //broadcast from rootScope and receive on $scope, this is fucking confusing
688
+ //console.log('emit someEvent', $scope.status.trial.runtime.secondsElapsedStr)
689
+ //$rootScope.$broadcast('someEvent', $scope.status.trial.runtime.secondsElapsedStr);
690
+
691
+ console . log ( 'emit rootEvent' , $scope . status . trial . runtime . secondsElapsedStr )
692
+ //$rootScope.$broadcast('rootEvent', 'Hello from the rootScope!');
693
+ //$rootScope.$emit("rootEvent", 'Hello from the rootScope!');
694
+ $rootScope . $broadcast ( "rootEvent2" , $scope . status . trial . runtime . secondsElapsedStr ) ;
695
+ //$scope.$broadcast('rootEvent', 'Hello from the rootScope!');
696
+ //$scope.$emit('rootEvent', 'Hello from the rootScope!');
697
+
698
+ //$scope.$emit('someEvent', $scope.status.trial.runtime.secondsElapsedStr);
699
+ // this will be captured/responded in motor controller with
700
+ // motor controller repsonds with
701
+ //$scope.$on('someEvent', function(event, args) {});
581
702
}
582
703
583
704
$scope . setInterval = function ( state ) {
0 commit comments