Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

how to reset.trace individual lines ? post and replies

Return to the how to reset.trace individual lines ? thread
Login to post to this thread

an example of a recording data function that still remember the trace data even after _initialize(); - Aug 13, 2013 at 5:41AM
lookang Avatar
lookang
116 Posts

dear professor paco and wolfgang,

is there an example of a recording data function that still remember the trace data even after _initialize(); ?

in the example attached (see zip file), i added a initialize button but the record data disappears when _initialize().

i need to figure out a way to record data for student to work on the recorded data.

thanks! i am working on adding new features onto this model by prof todd https://dl.dropboxusercontent.com/u/44365627/lookangEJSworkspace/export/ejs_KeplerSystem3rdLaw04.jar

Attached File: ejs_PointCharge.zip


http://weelookang.blogspot.sg

Replies to an example of a recording data function that still remember the trace data even after _initialize();

Re: an example of a recording data function that still remember the trace data even after _initialize(); - Aug 13 2013 7:02AM
Wolfgang
77 Posts

Lookang--

There are two ways to save recorded data.

1) You can store the data in an array that is not erased.
2) You can transfer the data to the Data Tool.

You can send data to the Data Tool using the following code:

_tools.showDataTool(_view.dataElement);

Here is a program that uses the Data Tool:

http://www.compadre.org/osp/items/detail.cfm?ID=9661


Wolfgang



Re: Re: an example of a recording data function that still remember the trace data even after _initialize(); - Aug 13 2013 11:39AM
lookang Avatar
lookang
116 Posts

dear prof wolfgang, the example http://www.compadre.org/osp/items/detail.cfm?ID=9661 has the same effect as the zip file i attached in the earlier post.

 

when the code _initialize() is run, the data is erase. the code _tools.showDataTool(_view.xytrail,_view.Etrail,_view.Vtrail) didn't allow me to figure out a way to store the data as in your reply "1) You can store the data in an array that is not erased."

 

i was looking at the codes in custom function called RecordData () 

//this section of the model is correct as well

//it recorded the data in a table

public void recordData () {

collectData = false;

magRow[0]=t; // period  //question //i can't figure out how to store this permanently for another run data to be added on.

magRow[1]=r; // radius //

_view.xytrail //adding points to a trail to be accessed by dataTool _view.xytrail.newSegment(); //

_view.xytrail.addPoint(t, r);

collectData = true; }

may i request for another example that you can create quickly for this effect "1) You can store the data in an array that is not erased." thanks! :)

Post edited August 13, 2013 at 12:03 PM EST.

Post edited August 13, 2013 at 12:03 PM EST.

Post edited August 13, 2013 at 12:04 PM EST.

Post edited August 13, 2013 at 12:05 PM EST.


http://weelookang.blogspot.sg


Re: an example of a recording data function that still remember the trace data even after _initialize(); - Aug 13 2013 7:24AM
Francisco Esquembre
144 Posts

Hi Lookang,

Trails can have more than one "segments". Each segment can have a different color. But what is important for your question is that _initialize() only clears the current segment. NOT previous segments.

The key then is to create a new segment before calling _initialize. You create a new segment with the method:
_view.trail.newSegment();

See attached example.

Cheers,

Paco

Attached File: ejs_NewSegmentTrailExample.zip



Re: Re: an example of a recording data function that still remember the trace data even after _initialize(); - Aug 13 2013 12:44PM
lookang Avatar
lookang
116 Posts

dear prof paco,

your tip is useful and implemented in my model here https://dl.dropboxusercontent.com/u/44365627/lookangEJSworkspace/export/ejs_KeplerSystem3rdLaw05.jar

i am one step closer to my design idea :)

but how can i save the 

_view.xytrail.newSegment(); into a Data table of input which is define as magRow

 

 

Post edited August 13, 2013 at 12:45 PM EST.

Attached File: store_data_2013-08-14_0037.png


http://weelookang.blogspot.sg


Re: Re: an example of a recording data function that still remember the trace data even after _initialize(); - Aug 13 2013 5:20PM
Francisco Esquembre
144 Posts

Do you mean to save data to disk and then read it at start up?

See attached example.

Paco

Attached File: WritingAndReadingASCII.ejs.zip



Re: Re: Re: an example of a recording data function that still remember the trace data even after _initialize(); - Aug 20 2013 1:24AM
lookang Avatar
lookang
116 Posts

thanks wolfgang and paco. i decide to use the right click save and read function in EJS, easier for students.

 

after working on this for a couple of days, this is the best i can do :)

 

this is the finalized model http://weelookang.blogspot.sg/2013/08/enhanced-keplers-model-after-student.html

 

version 20August 2013. http://weelookang.blogspot.com/2010/06/ejs-open-source-kepler-system-model-by.html
prototype: https://dl.dropboxusercontent.com/u/44365627/lookangEJSworkspace/export/ejs_KeplerSystem3rdLaw09.jar
older version:https://dl.dropbox.com/u/44365627/lookangEJSworkspace/export/ejs_KeplerSystem3rdLaw03.jar
author: timberlake and lookang
worksheets by (lead) YJC: same link of four simulations https://www.dropbox.com/s/53vztw6meupn4r5/GravitationYJC.zip

http://weelookang.blogspot.sg


The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics