Skip to content

Commit

Permalink
UPDATE creative-connections/ Bodylight-Scenarios/#53 fmi listen to 'i…
Browse files Browse the repository at this point in the history
…nput' event by default
  • Loading branch information
TomasKulhanek committed Jun 22, 2021
1 parent 0fe64bc commit ff7c617
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/usersguide/fmi.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
* `guid` guid as it appears in FMU model description
* `valuereferences` references to variables, custom event 'fmidata' with `event.detail` set to `{time: number , data:[number,...]}` where time is timepoint of the current simulation step and data is array of values in same order as in
valuereferences
* `inputs` id of component, value reference, optional nominator,denominator to normalize `value * nominator / denominator` all delimited by coma`,`, other inputs delimited by semicolon `;` e.g. `inputs="id1,1677323,1,60;id2,16725364"` cause that the value from id1 will be converted `x= valueid1 *1/60` and value from id2 `x = valueid2*1/1` ;
* `inputs` id of component, value reference, optional nominator,denominator to normalize `value * nominator / denominator` all delimited by coma`,`, other inputs delimited by semicolon `;` e.g. `inputs="id1,1677323,1,60;id2,16725364"` cause that the value from id1 will be converted `x= valueid1 *1/60` and value from id2 `x = valueid2*1/1` ;
* `eventlisten` event to listen on input elements - default "input" event - change is fired hen e.g. cursor is moved. You may change it to "change" - it is fired only when user drops the vlaue/ confirms the change.
* `otherinputs` ids of components which triggers custom event 'fmiinput', it is expected that in event.detail contains
this structure `{ valuereference: number, value: number }`
* `showcontrols` - default `true`, shows/hides basic control buttons to start/stop/restart simulation
* `fpslimit` - 1-60, default 60 = unlimited (default FPS allowed by browser). This attribute will limit the frames per second

and for values <60 will introduce some artificial delay to reduce framerate to the desired value. The limiting range is also available in UI.

Example:
Expand Down
1 change: 1 addition & 0 deletions docs/usersguide/pdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ To visualize molecule in PDB database
* width, height - set width and height of canvas to render pdbe component, include unit in css, e.g. '300px' or '100%'
* visual-style - set visual style - "cartoon","ball-and-stick",...
* show-ions - comma separated labels of ions to be shown differently using gaussian-surface - big balls
* custom-data-url - sets url to custom pdb file

The component renders by default window with width 100% and height 400px and set's automatic spin of the molecule for 60s.

Expand Down
4 changes: 3 additions & 1 deletion src/elements/fmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Fmi {
@bindable fpslimit = 60;
@bindable showtime = false;
@bindable showtimemultiply = 1;
@bindable eventlisten = 'input';//input==continuous/change==when user drops the value

cosimulation=1;
stepSize=0.01;//0.0078125;
Expand Down Expand Up @@ -92,7 +93,8 @@ export class Fmi {
this.inputreferences[myinputs[0]] = {ref: myinputs[1], numerator: numerator, denominator: denominator, addconst: addconst, fixed: fixedsignature}; //first is id second is reference
//register change event - the alteration is commited
let dependentEl = document.getElementById(myinputs[0]);
if (dependentEl) dependentEl.addEventListener('change', this.handleValueChange);
//now register 'change' event or eventlisten
if (dependentEl) dependentEl.addEventListener(this.eventlisten, this.handleValueChange);
else console.warn('cannot register changes for non-existing element id:', myinputs[0]);
console.log('registering input, ref, num,den,add,fixed', myinputs[0], myinputs[1], numerator, denominator, addconst, fixedsignature);
}
Expand Down

0 comments on commit ff7c617

Please sign in to comment.