question

Rafael de Assis avatar image
0 Likes"
Rafael de Assis asked Jason Lightfoot edited

How do I make a AGV level battery display?

I would like to make a display whith shows the battery level of AGV, I would like that display stayed in side of park point. I looked for some similar project, but I dont find or I cant open de file because de version.

Modelo situação AGV elevador.fsm

FlexSim 21.1.5
agv battery leveldisplay
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Jason Lightfoot edited

You can use a Text object to display the battery level. You only need a reference to the AGV, which you could get by setting up a pointer label on the text object.

You read the battery level through "AGV(reference).batteryLevel". To have the text show this value, convert it to a string and assing it to the "textnode" treenode variable in the Text Display code.

modelo-situacao-agv-elevador-fm.fsm


· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Rafael de Assis avatar image Rafael de Assis commented ·
Thank you!
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Rafael de Assis commented ·

Here's some battery level indicator draw code for the agv object (for those finding this post from the title but wanting a graphical representation):

// If this function returns a true, the default draw code of the object will not be executed.
drawtomodelscale(current);


Vec3 p1=Vec3(current.size.x*0.2,current.size.y*-0.5,current.size.z*1.2);
Vec3 rsize=Vec3(current.size.x*0.6,0,0.3);
Vec3 p3=p1+rsize;
Vec3 p2=p1+Vec3(rsize.x,0,0);
Vec3 p4=p1+Vec3(0,0,rsize.z);
double pcCharge=AGV(current).batteryLevel;
Color battCol=Color.fromPalette(pcCharge,"BatteryColor");
double r=battCol.r;
double g=battCol.g;
double b=battCol.b;
drawline(view,p1.x,p1.y,p1.z,p2.x,p2.y,p2.z,r,g,b);
drawline(view,p2.x,p2.y,p2.z,p3.x,p3.y,p3.z,r,g,b);
drawline(view,p3.x,p3.y,p3.z,p4.x,p4.y,p4.z,r,g,b);
drawline(view,p4.x,p4.y,p4.z,p1.x,p1.y,p1.z,r,g,b);
drawrectangle(p1.x,p1.y,p1.z,rsize.x*pcCharge/100,rsize.z,-90,0,0,255*r,255*g,255*b,1);
drawtoobjectscale(current);

1701263546092.png

1694525518050.png

The code uses a color pallet:

1701263573333.png


Example model:

AGVbatteryIndicator.fsm


0 Likes 0 ·