Skip to content

Commit

Permalink
Merge pull request #329 from harena-lab/development
Browse files Browse the repository at this point in the history
Better Player Environment
  • Loading branch information
santanche authored Jan 31, 2022
2 parents 094846d + 89fec10 commit 4211dd6
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ class RuleDCCCellNeighbor extends RuleDCCTransition {

notify (topic, message) {
switch (topic.toLowerCase()) {
case 'probability': this.probability = message.value; break
case 'probability':
this.probability =
(message.value != null) ? message.value : message.body;
break
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/adonisjs/public/dccs/components/control/dcc-compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,15 @@ class DCCCompute extends DCCBase {
this.setAttribute('dependency', newValue)
}

notify (topic, message) {
if (topic.toLowerCase() == 'update')
async notify (topic, message) {
const tp = topic.toLowerCase()
if (tp == 'update')
this.update()
else if (tp.startsWith('var/')) {
await this._request('var/set/' + tp.substring(4).replace(/\./g, '/'),
message.value)
this.update()
}
}

async update () {
Expand Down
2 changes: 0 additions & 2 deletions src/adonisjs/public/dccs/components/visual/dcc-expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class DCCExpression extends DCCVisual {
// also monitors all messages
if (this.active) {
this.stateChanged = this.stateChanged.bind(this)
console.log('=== component bus')
console.log(this._bus)
this._subscribe('input/state/#', this.stateChanged)
this._stateValues = {}
}
Expand Down
31 changes: 29 additions & 2 deletions src/adonisjs/public/player/js/htracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Tracker {
this.caseCompleted = this.caseCompleted.bind(this)
MessageBus.i.subscribe('case/completed/+', this.caseCompleted)
MessageBus.i.subscribe('session/close', this.caseCompleted)
this.caseTryHalt = this.caseTryHalt.bind(this)
MessageBus.i.subscribe('case/tryhalt', this.caseTryHalt)

this.submitVariables = this.submitVariables.bind(this)
MessageBus.i.subscribe('input/submit/*', this.submitVariables)
Expand All @@ -28,6 +30,7 @@ class Tracker {
initializeTrack () {
this._variables = {}
this._varUpdated = {}
this._varTrack = []
// this._varChanged = {} <FUTURE>
this._mandatoryFilled = {}
this._groupInput = null
Expand Down Expand Up @@ -81,6 +84,11 @@ class Tracker {
}

inputChanged (topic, message) {
const varid = this._extractEntityId(topic, 3)
const currentDateTime = new Date()
const tr = {changed: currentDateTime.toJSON()}
tr[varid] = message.value
this._varTrack.push(tr)
this._updateVariable(this._extractEntityId(topic, 3), message.value)
// this._changedVariable(topic, message.value) <FUTURE>
}
Expand Down Expand Up @@ -157,10 +165,26 @@ class Tracker {
{userId: message.userId,
caseId: message.caseId,
knotTrack: this._knotTrack,
variables: this._variables}, true)
variables: this._variables,
varTrack: this._varTrack}, true)
}
}

async caseTryHalt (userId, caseId, instanceId) {
const currentDateTime = new Date()
this._knotTrack.push(
{event: '*** try case halt ***',
timeResume: currentDateTime.toJSON()}
)
this._variables['try case halt'] = '*** try case halt ***'
await MessageBus.i.publish('case/summary/' + instanceId,
{userId: userId,
caseId: caseId,
knotTrack: this._knotTrack,
variables: this._variables,
varTrack: this._varTrack}, true)
}

caseHalt (userId, caseId, instanceId) {
const track = this._trackRetrieve()
if (track != null) {
Expand All @@ -174,7 +198,8 @@ class Tracker {
{userId: userId,
caseId: caseId,
knotTrack: track.knotTrack,
variables: track.variables}, true)
variables: track.variables,
varTrack: this._varTrack}, true)
}
}

Expand All @@ -187,6 +212,7 @@ class Tracker {
{knotTrack: this._knotTrack,
variables: this._variables,
varUpdated: this._varUpdated,
varTrack: this._varTrack,
mandatoryFilled: this._mandatoryFilled,
groupInput: this._groupInput,
caseCompleted: this._caseCompleted
Expand All @@ -207,6 +233,7 @@ class Tracker {
if (track != null) {
this._knotTrack = track.knotTrack
this._variables = track.variables
this._varTrack = track.varTrack
this._varUpdated = track.varUpdated
this._mandatoryFilled = track.mandatoryFilled
this._groupInput = track.groupInput
Expand Down
16 changes: 16 additions & 0 deletions src/adonisjs/public/player/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,26 @@ class PlayerManager {
}
*/

async tryHalt () {
try {
const pPlay = this._state.pendingPlayCheck()
if (!this._previewCase && pPlay != null && pPlay.running)
this._tracker.caseTryHalt(pPlay.userid, pPlay.caseid, pPlay.running.runningId)
} catch (e) {
console.log('=== error on halt')
console.log(e)
}
return ''
}

async startPlayer (caseid) {
this.tryHalt = this.tryHalt.bind(this)
window.onbeforeunload = this.tryHalt
/*
window.onbeforeunload = function() {
return "";
}
*/
const resumeActive = true // activates and deactivates case resume
this._mainPanel = document.querySelector('#player-panel')

Expand Down
7 changes: 7 additions & 0 deletions src/adonisjs/public/themes/plain/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ body {
margin-left: 6px
}

/* Input Typed DCC
*****************/

.dcc-input-typed-theme input textarea {
font-size: 4vh;
}

/* Button DCC
************/

Expand Down

0 comments on commit 4211dd6

Please sign in to comment.