@decidables/accumulable-elements 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- // import DDMMath from '@decidables/accumulable-math';
2
+ import DDMMath from '@decidables/accumulable-math';
3
3
 
4
4
  import DDMExample from './ddm-example';
5
5
 
@@ -63,10 +63,10 @@ export default class DDMExampleModel extends DDMExample {
63
63
  this.colors = ['none', 'measure', 'outcome', 'all'];
64
64
  this.color = 'outcome';
65
65
 
66
- this.a = 1.2;
67
- this.z = 0.35;
68
- this.v = 1.5;
69
- this.t0 = 150;
66
+ this.a = DDMMath.a.DEFAULT;
67
+ this.z = DDMMath.z.DEFAULT;
68
+ this.v = DDMMath.v.DEFAULT;
69
+ this.t0 = DDMMath.t0.DEFAULT;
70
70
 
71
71
  this.accumulableControl = null;
72
72
  this.rdkTask = null;
@@ -93,70 +93,58 @@ export default class DDMExampleModel extends DDMExample {
93
93
  this.accumulableTable = this.querySelector('accumulable-table');
94
94
 
95
95
  if (this.accumulableControl) {
96
- if (this.accumulableControl.hasAttribute('trials')) {
97
- this.accumulableControl.addEventListener('accumulable-control-trials', (event) => {
98
- this.trials = event.detail.trials;
99
- });
100
- }
101
-
102
- if (this.accumulableControl.hasAttribute('duration')) {
103
- this.accumulableControl.addEventListener('accumulable-control-duration', (event) => {
104
- this.duration = event.detail.duration;
105
- });
106
- }
107
-
108
- if (this.accumulableControl.hasAttribute('color')) {
109
- this.accumulableControl.addEventListener('accumulable-control-color', (event) => {
110
- this.color = event.detail.color;
111
- });
112
- }
113
-
114
- if (this.accumulableControl.hasAttribute('run')) {
115
- this.accumulableControl.addEventListener('accumulable-control-run', (/* event */) => {
116
- if (this.rdkTask) {
117
- this.rdkTask.running = true;
118
- }
119
-
120
- if (this.ddmModel) {
121
- this.ddmModel.resumeTrial();
122
- }
123
- });
124
- }
125
-
126
- if (this.accumulableControl.hasAttribute('pause')) {
127
- this.accumulableControl.addEventListener('accumulable-control-pause', (/* event */) => {
128
- if (this.rdkTask) {
129
- this.rdkTask.running = false;
130
- }
131
-
132
- if (this.ddmModel) {
133
- this.ddmModel.pauseTrial();
134
- }
135
- });
136
- }
137
-
138
- if (this.accumulableControl.hasAttribute('reset')) {
139
- this.accumulableControl.addEventListener('accumulable-control-reset', (/* event */) => {
140
- this.trialCount = 0;
141
- this.signal = undefined;
142
-
143
- if (this.rdkTask) {
144
- this.rdkTask.reset();
145
- }
146
-
147
- if (this.ddmModel) {
148
- this.ddmModel.trials = this.trialCount;
149
- }
150
-
151
- if (this.accumulableResponse) {
152
- this.accumulableResponse.reset();
153
- }
154
-
155
- if (this.accumulableTable) {
156
- // this.accumulableTable.clear();
157
- }
158
- });
159
- }
96
+ this.accumulableControl.addEventListener('accumulable-control-trials', (event) => {
97
+ this.trials = event.detail.trials;
98
+ });
99
+
100
+ this.accumulableControl.addEventListener('accumulable-control-duration', (event) => {
101
+ this.duration = event.detail.duration;
102
+ });
103
+
104
+ this.accumulableControl.addEventListener('accumulable-control-color', (event) => {
105
+ this.color = event.detail.color;
106
+ });
107
+
108
+ this.accumulableControl.addEventListener('accumulable-control-run', (/* event */) => {
109
+ if (this.rdkTask) {
110
+ this.rdkTask.running = true;
111
+ }
112
+
113
+ if (this.ddmModel) {
114
+ this.ddmModel.resumeTrial();
115
+ }
116
+ });
117
+
118
+ this.accumulableControl.addEventListener('accumulable-control-pause', (/* event */) => {
119
+ if (this.rdkTask) {
120
+ this.rdkTask.running = false;
121
+ }
122
+
123
+ if (this.ddmModel) {
124
+ this.ddmModel.pauseTrial();
125
+ }
126
+ });
127
+
128
+ this.accumulableControl.addEventListener('accumulable-control-reset', (/* event */) => {
129
+ this.trialCount = 0;
130
+ this.signal = undefined;
131
+
132
+ if (this.rdkTask) {
133
+ this.rdkTask.reset();
134
+ }
135
+
136
+ if (this.ddmModel) {
137
+ this.ddmModel.trials = this.trialCount;
138
+ }
139
+
140
+ if (this.accumulableResponse) {
141
+ this.accumulableResponse.reset();
142
+ }
143
+
144
+ if (this.accumulableTable) {
145
+ // this.accumulableTable.clear();
146
+ }
147
+ });
160
148
  }
161
149
 
162
150
  if (this.rdkTask) {
@@ -225,22 +213,20 @@ export default class DDMExampleModel extends DDMExample {
225
213
  this.requestUpdate();
226
214
  });
227
215
 
228
- if (this.ddmModel) {
229
- this.ddmModel.addEventListener('accumulable-response', (event) => {
230
- if (this.accumulableResponse) {
231
- const response = (event.detail.outcome === 'correct')
232
- ? this.signal
233
- : (this.signal === 'left')
234
- ? 'right'
235
- : 'left';
236
- this.accumulableResponse.responded(response);
237
- }
238
-
239
- this.data = event.detail.data;
240
- this.model = event.detail.model;
241
- this.requestUpdate();
242
- });
243
- }
216
+ this.ddmModel.addEventListener('accumulable-response', (event) => {
217
+ if (this.accumulableResponse) {
218
+ const response = (event.detail.outcome === 'correct')
219
+ ? this.signal
220
+ : (this.signal === 'left')
221
+ ? 'right'
222
+ : 'left';
223
+ this.accumulableResponse.responded(response);
224
+ }
225
+
226
+ this.data = event.detail.data;
227
+ this.model = event.detail.model;
228
+ this.requestUpdate();
229
+ });
244
230
  }
245
231
 
246
232
  this.requestUpdate();
@@ -254,10 +240,18 @@ export default class DDMExampleModel extends DDMExample {
254
240
  }
255
241
 
256
242
  if (this.accumulableControl) {
257
- this.accumulableControl.trials = this.trials;
258
- this.accumulableControl.duration = this.duration;
259
- this.accumulableControl.coherence = this.coherence;
260
- this.accumulableControl.color = this.color;
243
+ this.accumulableControl.trials = (this.accumulableControl.trials != null)
244
+ ? this.trials
245
+ : undefined;
246
+ this.accumulableControl.duration = (this.accumulableControl.duration != null)
247
+ ? this.duration
248
+ : undefined;
249
+ this.accumulableControl.coherence = (this.accumulableControl.coherence != null)
250
+ ? this.coherence
251
+ : undefined;
252
+ this.accumulableControl.color = (this.accumulableControl.color != null)
253
+ ? this.color
254
+ : undefined;
261
255
  }
262
256
 
263
257
  if (this.rdkTask) {
@@ -267,10 +261,18 @@ export default class DDMExampleModel extends DDMExample {
267
261
  }
268
262
 
269
263
  if (this.ddmParameters) {
270
- this.ddmParameters.a = this.a;
271
- this.ddmParameters.z = this.z;
272
- this.ddmParameters.v = this.v;
273
- this.ddmParameters.t0 = this.t0;
264
+ this.ddmParameters.a = (this.ddmParameters.a != null)
265
+ ? this.a
266
+ : undefined;
267
+ this.ddmParameters.z = (this.ddmParameters.z != null)
268
+ ? this.z
269
+ : undefined;
270
+ this.ddmParameters.v = (this.ddmParameters.a != null)
271
+ ? this.v
272
+ : undefined;
273
+ this.ddmParameters.t0 = (this.ddmParameters.t0 != null)
274
+ ? this.t0
275
+ : undefined;
274
276
  }
275
277
 
276
278
  if (this.ddmModel) {