Circular Running Status Implemented and working
This commit is contained in:
1 parent
b83418c772
commit
fb31f1f255
4 files changed
+141
-26
No files matched your search
@@ -0,0 +1,109 @@
|
||||
|
||||
function newCircularRunningStatus () {
|
||||
const MODULE_NAME = 'Circular Running Status'
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
isDeployed: undefined,
|
||||
physics: physics,
|
||||
drawBackground: drawBackground,
|
||||
drawForeground: drawForeground,
|
||||
getContainer: getContainer,
|
||||
finalize: finalize,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize(MODULE_NAME, 'Circle')
|
||||
thisObject.container.isClickeable = false
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.radius = 0
|
||||
thisObject.container.frame.position.x = 0
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
let opacityCounters = []
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
|
||||
thisObject.payload = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
}
|
||||
|
||||
function initialize (payload) {
|
||||
thisObject.payload = payload
|
||||
|
||||
for (let i = 0; i < 60; i++) {
|
||||
opacityCounters.push(0)
|
||||
}
|
||||
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type
|
||||
systemEventHandler.createEventHandler(key)
|
||||
systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, key, undefined, onHeartBeat)
|
||||
}
|
||||
|
||||
function onHeartBeat (message) {
|
||||
opacityCounters[message.event.seconds] = 2000
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
let container
|
||||
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menutItem = menuItems[i]
|
||||
container = menutItem.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
for (let i = 0; i < 60; i++) {
|
||||
opacityCounters[i]--
|
||||
|
||||
if (opacityCounters[i] < 0) {
|
||||
opacityCounters[i] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawBackground (pFloatingObject) {
|
||||
const VISIBLE_RADIUS = thisObject.container.frame.radius * 2
|
||||
|
||||
let visiblePosition = {
|
||||
x: thisObject.container.frame.position.x,
|
||||
y: thisObject.container.frame.position.y
|
||||
}
|
||||
|
||||
visiblePosition = thisObject.container.frame.frameThisPoint(visiblePosition)
|
||||
visiblePosition = thisObject.fitFunction(visiblePosition)
|
||||
|
||||
for (let i = 0; i < 60; i++) {
|
||||
let OPACITY = opacityCounters[i] / 1000
|
||||
|
||||
let initialAngle = Math.PI * 2 / 60 * i - Math.PI / 2
|
||||
let finalAngle = Math.PI * 2 / 60 * (i + 1) - Math.PI / 2
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, initialAngle, finalAngle, false)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GOLDEN_ORANGE + ', ' + OPACITY * 2 + ')'
|
||||
browserCanvasContext.lineWidth = 6 + opacityCounters[i] / 100
|
||||
browserCanvasContext.setLineDash([3, 4])
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK_TURQUOISE + ', ' + OPACITY + ')'
|
||||
browserCanvasContext.lineWidth = 0 + opacityCounters[i] / 100
|
||||
browserCanvasContext.setLineDash([3, 4])
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
|
||||
function drawForeground (pFloatingObject) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,12 @@ function newStrategyPart () {
|
||||
payload: undefined,
|
||||
codeEditor: undefined,
|
||||
partTitle: undefined,
|
||||
runningStatus: undefined,
|
||||
isExecuting: undefined,
|
||||
isRunning: undefined,
|
||||
run: run,
|
||||
runX: runX,
|
||||
stop: stop,
|
||||
setRunningStatus: setRunningStatus,
|
||||
setNotRunningStatus: setNotRunningStatus,
|
||||
getReadyToAttach: getReadyToAttach,
|
||||
@@ -175,8 +178,11 @@ function newStrategyPart () {
|
||||
thisObject.payload.targetPosition.y = thisObject.payload.chainParent.payload.position.y
|
||||
}
|
||||
|
||||
if (thisObject.runningStatus !== undefined) {
|
||||
thisObject.runningStatus.physics()
|
||||
}
|
||||
|
||||
iconPhysics()
|
||||
runningPhisycs()
|
||||
highlightPhisycs()
|
||||
errorMessagePhisycs()
|
||||
valuePhisycs()
|
||||
@@ -525,17 +531,20 @@ function newStrategyPart () {
|
||||
}
|
||||
}
|
||||
|
||||
function runningPhisycs () {
|
||||
if (canvas.strategySpace.workspace.definition !== undefined) {
|
||||
if (canvas.strategySpace.workspace.definition.id !== thisObject.payload.node.id) {
|
||||
runningCounter--
|
||||
}
|
||||
function runX () {
|
||||
if (thisObject.runningStatus !== undefined) {
|
||||
thisObject.runningStatus.finalize()
|
||||
}
|
||||
|
||||
if (runningCounter < 0) {
|
||||
runningCounter = 0
|
||||
thisObject.isRunning = false
|
||||
}
|
||||
thisObject.runningStatus = newCircularRunningStatus()
|
||||
thisObject.runningStatus.initialize(thisObject.payload)
|
||||
thisObject.runningStatus.fitFunction = thisObject.fitFunction
|
||||
thisObject.runningStatus.container = thisObject.container
|
||||
}
|
||||
|
||||
function stop () {
|
||||
thisObject.runningStatus.finalize()
|
||||
thisObject.runningStatus = undefined
|
||||
}
|
||||
|
||||
function run () {
|
||||
@@ -604,6 +613,10 @@ function newStrategyPart () {
|
||||
thisObject.menu.drawBackground()
|
||||
}
|
||||
}
|
||||
|
||||
if (thisObject.runningStatus !== undefined) {
|
||||
thisObject.runningStatus.drawBackground()
|
||||
}
|
||||
}
|
||||
|
||||
function drawMiddleground () {
|
||||
@@ -621,6 +634,10 @@ function newStrategyPart () {
|
||||
thisObject.menu.drawForeground()
|
||||
}
|
||||
}
|
||||
|
||||
if (thisObject.runningStatus !== undefined) {
|
||||
thisObject.runningStatus.drawForeground()
|
||||
}
|
||||
}
|
||||
|
||||
function drawOnFocus () {
|
||||
@@ -931,21 +948,6 @@ function newStrategyPart () {
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
|
||||
if (thisObject.isRunning === true) {
|
||||
VISIBLE_RADIUS = thisObject.container.frame.radius * 2
|
||||
let OPACITY = runningCounter / 30
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + OPACITY + ')'
|
||||
|
||||
browserCanvasContext.lineWidth = 10
|
||||
browserCanvasContext.setLineDash([4, 20])
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
|
||||
if (hasError === true) {
|
||||
VISIBLE_RADIUS = thisObject.container.frame.radius * 1
|
||||
let OPACITY = errorMessageCounter / 30
|
||||
|
||||
@@ -2145,7 +2145,7 @@ function newStrategyPartConstructor () {
|
||||
break
|
||||
}
|
||||
case 'Backend Process': {
|
||||
level_2()
|
||||
level_1()
|
||||
break
|
||||
}
|
||||
case 'Sensor': {
|
||||
|
||||
@@ -215,6 +215,8 @@ function newWorkspace () {
|
||||
if (payload.node.bot === undefined) { return }
|
||||
if (payload.node.bot.botProcesses.length === 0) { return }
|
||||
|
||||
payload.uiObject.runX()
|
||||
|
||||
let event = {
|
||||
backendProcessId: payload.node.id,
|
||||
definition: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false, true)) // <- We need to do this workaround in order no to send unescaped charactars to the backend.
|
||||
@@ -228,6 +230,8 @@ function newWorkspace () {
|
||||
backendProcessId: payload.node.id
|
||||
}
|
||||
systemEventHandler.raiseEvent('Backend Server', 'Stop Backend Process', event)
|
||||
|
||||
payload.uiObject.stop()
|
||||
}
|
||||
break
|
||||
case 'Add Backend':
|
||||
|
||||
Reference in new issue
Block a user