single dashboard for two boards connected to two FreeMaster on the same computer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

single dashboard for two boards connected to two FreeMaster on the same computer

Jump to solution
1,571 Views
Ahmed_Abd_El-Hafez
Contributor III

Can you please tell me how to create one single dashboard in html and java script that can collect data from all the multiple Freemaster (or two ) instances and control all connected boards? .I focus on JSON-RPC communication and I had little experience in the design of dashboards.

0 Kudos
1 Solution
1,279 Views
MichalH
NXP Apps Support
NXP Apps Support

Hello, I'm not sure if I understand it correctly. A block diagram could help to describe your instances, boards and controls in the common dashboard. Are you hosting any HTML application inside any of the FreeMASTER windows? Where do you host the common dashboard?

Do you use the same project file (pmp) in each of the two FreeMASTER instances? If not, then you can differentiate the instances visually somehow (e.g. set different title of the root project node, use different background colors in the html page etc.).

When you run the FreeMASTER (pcmaster.exe), you may pass it a command line argument /rpcs N where N is the number of JSON-RPC port it will use. If you do not pass this parameter, the first started instance will use 41000 and the others will increment this number.   So if you would use the parameter when starting both instances, you can then know which one is pcm1 and which one is pcm2.

Refer to User Guide for description of the /rpcs parameter.

Regards,
Michal

View solution in original post

0 Kudos
12 Replies
1,555 Views
MichalH
NXP Apps Support
NXP Apps Support

Dear Ahmed,

Actually, User Guide section 6.9 explains some of this topic. Let me summarize:

Each FreeMASTER's JSON-RPC server listens on a different port. The first instance is 41000 and others then try to increment the port number until they are successful opening the socket. To have this more under control, you can start the FreeMASTER with /rpcs N option as described in section 6.3 of the User Guide. 

When each instance runs (and connects to its target board), you can then use one HTML application running either inside of one of the FreeMASTERs or separately in a web browser to connect to both instances.

I assume you will use the freemaster-client.js module for the benefit of having a "PCM" object wrapper around the JSON-RPC communication. Refer to example in "c:\NXP\FreeMASTER 3.2\FreeMASTER\examples\scripting\JavaScript-JSON-RPC\example.htm" for more details. You can easily extend this example by having two PCM object instances, each connected to different FreeMASTER instance:

pcm1 = new PCM("localhost:41000", on_connected1, on_error, on_error);
pcm2 = new PCM("localhost:41001", on_connected2, on_error, on_error);

Now you can call methods like ReadVariable for either of the object instance (pcm1 or pcm2).

Regards,
Michal

0 Kudos
1,302 Views
Ahmed_Abd_El-Hafez
Contributor III

Dear MichaIH,

How can I tell it that pcm1 is related to the first instance and the pcm2 is related to the second instance of freemaster so that pcm1 methods can't change in the second instance and vice versa  ? 

0 Kudos
1,293 Views
MichalH
NXP Apps Support
NXP Apps Support

Hello Ahmed,

when running the FreeMASTER (pcmaster.exe) processes, you may pass the /rpcs 41000 and /rpcs 41001 server port numbers so you then know which instance is which.

Alternatively, you may use pcm1 or pcm2.GetProjectOptions()  method to retrieve "comm.rs232_conn" connection string and other communication parameters which may help you to determine to what physical board is each FreeMASTER instance connected to.

If you load two different .pmp project files in each FreeMASTER instance, then the best alternative is probably to add a "virtual variable" in each FreeMASTER project, name it the same way in both (e.g. project_id), but assign a different default value to each. Then this variable can be read by using pcm1 and pcm2.ReadVariable() method so you will determine who is who.

Regards,
Michal

0 Kudos
1,291 Views
Ahmed_Abd_El-Hafez
Contributor III

My problem is not to know which physical board is related to which freemaster instance. but to know which instance will be affected by which window in my GUI ( single dashboard but has windows to control motor1 and others for motor 2) I need to tell each pcm object to affect only a certain instance of freemaster.

I didn't get the point of passing /rpcs 41000 and /rpcs 41001. can you elaborate it more,please?

0 Kudos
1,280 Views
MichalH
NXP Apps Support
NXP Apps Support

Hello, I'm not sure if I understand it correctly. A block diagram could help to describe your instances, boards and controls in the common dashboard. Are you hosting any HTML application inside any of the FreeMASTER windows? Where do you host the common dashboard?

Do you use the same project file (pmp) in each of the two FreeMASTER instances? If not, then you can differentiate the instances visually somehow (e.g. set different title of the root project node, use different background colors in the html page etc.).

When you run the FreeMASTER (pcmaster.exe), you may pass it a command line argument /rpcs N where N is the number of JSON-RPC port it will use. If you do not pass this parameter, the first started instance will use 41000 and the others will increment this number.   So if you would use the parameter when starting both instances, you can then know which one is pcm1 and which one is pcm2.

Refer to User Guide for description of the /rpcs parameter.

Regards,
Michal

0 Kudos
1,263 Views
Ahmed_Abd_El-Hafez
Contributor III

Dear MichaI,

The problem was solved. I didn't take care that the two instances of freemaster  use 41000 and 41001 by default. this marked which one is corresponding to which pcm object.

Thank you very very much MichaI.

0 Kudos
1,532 Views
Ahmed_Abd_El-Hafez
Contributor III

Have I to change any thing in the " freemaster-client.js" and " simple-jsonrpc-js.js" files like adding lines for pcm2 or not ? 

0 Kudos
1,525 Views
MichalH
NXP Apps Support
NXP Apps Support

Hello, 

these files shall not be changed. You just want to create multiple instances of the PCM object. You should not need to change the PCM object implementation itself.

Regards,
Michal

0 Kudos
1,522 Views
Ahmed_Abd_El-Hafez
Contributor III

ok. Now I am confused about something else. that is there must be one element carrying the id of pcm or there must be two: one carrying id of pcm1 and the other carrying id of pcm2 ?

0 Kudos
1,520 Views
MichalH
NXP Apps Support
NXP Apps Support

I'm not sure what you mean by the "Id". Each instance (pcm1 and pcm2) maintains a connection to different FreeMASTER server. The first parameter passed to the PCM constructor actually identify which FreeMASTER instance you connect to.

So you start FreeMASTER #1 with parameter /rpcs 41000. Then you start FreeMASTER #2 with /rpcs 41001. 

Then you create pcm1 and pcm2 instances as I showed earlier, so pcm1 will talk to FreeMASTER #1 and pcm2 to FreeMASTER #2.

Does this help?

Regards,
Michal

0 Kudos
1,487 Views
Ahmed_Abd_El-Hafez
Contributor III

yes this helps, thank you very much Mr.MichaIH, I will continue trying it.

0 Kudos
1,552 Views
Ahmed_Abd_El-Hafez
Contributor III

Thank you very much Mr.MichalH. I will try it .

0 Kudos