diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index 2d3b9c35a..3b76c7698 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -307,6 +307,18 @@ function newPlottersManager () { } connector.nodesProgress.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesProgress.onRecordChange) } + if (plotterModule.nodesAnnouncements !== undefined && plotterModule.config.connectTo !== undefined) { + connector.nodesAnnounements = newNodesAnnouncements() + switch (plotterModule.config.connectTo) { + case 'Trading System': + connector.nodesAnnounements.initialize(tradingSystem) + break + case 'Trading Engine': + connector.nodesAnnounements.initialize(tradingEngine) + break + } + connector.nodesAnnounements.onRecordChangeEventsSubscriptionId = connector.plotter.container.eventHandler.listenToEvent('Current Record Changed', connector.nodesAnnounements.onRecordChange) + } /* Another type of plotting is with Record Values. This method uses the record definition to find the target node and from there is looks into its children all based on the Record Definition configuration. diff --git a/Panels/Layer.js b/Panels/Layer.js index bff8cc5a9..cc2514911 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -177,7 +177,7 @@ function newLayer () { 'Image->Image Condition->Image Position->Point->' + 'Text->Text Condition->Text Position->Point->Text Formula->Text Style->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' + - 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->Record Values->' + 'Nodes Highlights->Nodes Values->Nodes Errors->Nodes Status->Nodes Progress->Nodes Running->Nodes Announcements->Record Values->' thisObject.definition = functionLibraryProtocolNode.getProtocolNode(thisObject.payload.node, false, true, true, false, false, lightingPath) /* Here we validate that we have all the needed information */ diff --git a/Plotting/NodesAnnouncements.js b/Plotting/NodesAnnouncements.js new file mode 100644 index 000000000..be6d257ac --- /dev/null +++ b/Plotting/NodesAnnouncements.js @@ -0,0 +1,46 @@ +function newNodesAnnouncements () { + const MODULE_NAME = 'Nodes Announcements' + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + onRecordChange: onRecordChange, + initialize: initialize, + finalize: finalize + } + + let hiriarchyMap + return thisObject + + function finalize () { + hiriarchyMap = undefined + } + + function initialize (pRootNode) { + let rootNode = canvas.designSpace.workspace.getHierarchyHeadsById(pRootNode.id) + hiriarchyMap = getHiriarchyMap(rootNode) + } + + function onRecordChange (currentRecord) { + if (currentRecord === undefined) { return } + let array = currentRecord.announcements + if (array === undefined) { return } + for (let i = 0; i < array.length; i++) { + let arrayItem = array[i] + let nodeId = arrayItem[0] + let value = arrayItem[1] + applyValue(nodeId, value) + } + } + + function applyValue (nodeId, value) { + if (canvas.chartingSpace.visible !== true) { return } + let node = hiriarchyMap.get(nodeId) + if (node === undefined) { return } + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + if (value === true) { value = 'true' } + if (value === false) { value = 'false' } + node.payload.uiObject.setValue(value, 1) + } +}