Flexsim records the total travel distance by a task executor using the method.
TaskExecRef.as(TaskExecuter).stats.totalTravelDistance;
You can store this info into a tracked variable. And by using process flow you can listen to the tracked variable changes every 1 metre. Depending on the path that the agv is traveling, for every 1 m deduct the different battery consumption rates. In this case, since the battery charge depends on the distance traveled, the battery charge level can be a tracked variable label on the AGV.
To update the tracked variable as the travel distance updates. Add the total travel distance dashboard from the statistics toolbar. Install the statistics collector corresponding to it. Then add the abovementioned code in the statistics collector for updating the tracked variable. [ Note: When you do this method of tracked variable updation always keep the dashboard chart open, then only the tracked variable value gets updated. You can also try this kind of tracked variable updation in the OnDraw trigger of the agv.]
Add Chart
Create the process flow for listening to the tracked variable changes and deduct the battery level depending on the path. Create a global table that lists the battery consumption levels based on the path. Access this table in the process flow for deduction.
Here's the code.
Table BatteryInfo = Table("BatteryInfo_DistanceBased")
AGV agv = AGV(current);
Object Path = agv.currentTravelPathSection.path;// Gets the current path
int PathNum = Path.find(">variables/pathType").value;
string PathName = Model.find("AGVNetwork>variables/pathTypes").subnodes[PathNum].name;
double RateValue = Table.query("SELECT * FROM BatteryInfo_DistanceBased WHERE PathType = $1",PathName)[1][2];
current.labels["BatteryLevel"].value = current.labels["BatteryLevel"].value - RateValue;When the battery level reaches a threshold value or zero, add a recharge logic by adding additional process flow activities. agvSupport.fsm
Regards,
Arun KR