mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 23:20:50 +00:00
Moves domain object observe logic to the condition set telemetry provider
This commit is contained in:
parent
625b39d722
commit
649575fd2d
@ -45,38 +45,12 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// observeForChanges(conditionSetDomainObject) {
|
//this should not happen very frequently
|
||||||
// this.stopObservingForChanges = this.openmct.objects.observe(conditionSetDomainObject, 'configuration.conditionCollection', this.handleConditionCollectionUpdated.bind(this));
|
update(newConditionCollection) {
|
||||||
// }
|
this.destroy();
|
||||||
//
|
this.conditionSetDomainObject.configuration.conditionCollection = newConditionCollection;
|
||||||
// handleConditionCollectionUpdated(newConditionCollection) {
|
this.initialize();
|
||||||
// // let oldConditionIds = this.conditionSetDomainObject.configuration.conditionCollection.map((conditionConfiguration) => {
|
}
|
||||||
// // return conditionConfiguration.id;
|
|
||||||
// // });
|
|
||||||
// // let newConditionIds = newConditionCollection.map((conditionConfiguration) => {
|
|
||||||
// // return conditionConfiguration.id;
|
|
||||||
// // });
|
|
||||||
//
|
|
||||||
// this.conditionSetDomainObject.configuration.conditionCollection = newConditionCollection;
|
|
||||||
//
|
|
||||||
// // //check for removed conditions
|
|
||||||
// // oldConditionIds.forEach((id, index) => {
|
|
||||||
// // if (newConditionIds.indexOf(id) < 0) {
|
|
||||||
// // this.removeCondition(id);
|
|
||||||
// // }
|
|
||||||
// // });
|
|
||||||
//
|
|
||||||
// // const conditionSetDOConditionCollection = this.conditionSetDomainObject.configuration.conditionCollection;
|
|
||||||
// //should not need to check for removed conditions since this happens from the ConditionManager itself
|
|
||||||
//
|
|
||||||
// for (let i = 0; i < newConditionCollection.length; i++) {
|
|
||||||
// const conditionConfiguration = newConditionCollection[i];
|
|
||||||
// const found = this.findConditionById(conditionConfiguration.id);
|
|
||||||
// if (!found) {
|
|
||||||
// this.initCondition(conditionConfiguration, i);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
updateCondition(conditionConfiguration, index) {
|
updateCondition(conditionConfiguration, index) {
|
||||||
let condition = this.conditionClassCollection[index];
|
let condition = this.conditionClassCollection[index];
|
||||||
@ -240,9 +214,6 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
if (typeof this.stopObservingForChanges === 'function') {
|
|
||||||
this.stopObservingForChanges();
|
|
||||||
}
|
|
||||||
this.conditionClassCollection.forEach((condition) => {
|
this.conditionClassCollection.forEach((condition) => {
|
||||||
condition.off('conditionResultUpdated', this.handleConditionResult);
|
condition.off('conditionResultUpdated', this.handleConditionResult);
|
||||||
condition.destroy();
|
condition.destroy();
|
||||||
|
@ -1,3 +1,25 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2020, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
import ConditionManager from './ConditionManager'
|
import ConditionManager from './ConditionManager'
|
||||||
|
|
||||||
export default class ConditionSetTelemetryProvider {
|
export default class ConditionSetTelemetryProvider {
|
||||||
@ -21,9 +43,16 @@ export default class ConditionSetTelemetryProvider {
|
|||||||
let conditionManager = new ConditionManager(domainObject, this.openmct);
|
let conditionManager = new ConditionManager(domainObject, this.openmct);
|
||||||
conditionManager.on('conditionSetResultUpdated', callback);
|
conditionManager.on('conditionSetResultUpdated', callback);
|
||||||
|
|
||||||
|
let stopObservingForChanges = this.openmct.objects.observe(domainObject, 'configuration.conditionCollection', (newConditionCollection) => {
|
||||||
|
conditionManager.update(newConditionCollection);
|
||||||
|
});
|
||||||
|
|
||||||
return function unsubscribe() {
|
return function unsubscribe() {
|
||||||
conditionManager.off('conditionSetResultUpdated');
|
conditionManager.off('conditionSetResultUpdated');
|
||||||
conditionManager.destroy();
|
conditionManager.destroy();
|
||||||
|
if (stopObservingForChanges) {
|
||||||
|
stopObservingForChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,27 +58,15 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.conditionSetIdentifier = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
this.conditionSetIdentifier = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||||
this.observeForChanges();
|
|
||||||
this.provideTelemetry();
|
this.provideTelemetry();
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
if (this.stopProvidingTelemetry) {
|
if (this.stopProvidingTelemetry) {
|
||||||
this.stopProvidingTelemetry();
|
this.stopProvidingTelemetry();
|
||||||
}
|
}
|
||||||
if (this.stopObservingForChanges) {
|
|
||||||
this.stopObservingForChanges();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
observeForChanges() {
|
|
||||||
this.stopObservingForChanges = this.openmct.objects.observe(this.domainObject, '*', (newDomainObject) => {
|
|
||||||
//Since the domain object changes in conditionCollection.vue we need to resubscribe when that happens
|
|
||||||
this.domainObject = newDomainObject;
|
|
||||||
this.provideTelemetry();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
updateCurrentOutput(currentConditionResult) {
|
updateCurrentOutput(currentConditionResult) {
|
||||||
console.log(currentConditionResult);
|
|
||||||
this.currentConditionOutput = currentConditionResult.output;
|
this.currentConditionOutput = currentConditionResult.output;
|
||||||
},
|
},
|
||||||
provideTelemetry() {
|
provideTelemetry() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user