<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help on custom coding for battery charging in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502864#M17662</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you, Felix!&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Before I open another question, I need your recommendation on how to proceed on this: I want to track how much power is charged from each dock and how many ships are charging at the same time. Then I think I will not disturb you anymore as modeling will be mostly over &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;There could be a better way but I think I can utilize the loc. labels for this. There are .loc labels given for each ship after it departs to the destination dock e.g. BOS_F, BOS1, BOS2, BOS3..., KSK, KSK1, KSK2, KSK3... etc. When the ship is idle at the dock, it starts charging at a preset rate but I need to see the amount of power drawn from the dock "battery" at the completion of each ship's charge (when it is not at idle anymore) and how many ships are charging at the same time at a dock. I also need the daily total charge is drawn and daily average rates for each dock "batteries".&lt;/P&gt;
 &lt;P&gt;The math is simple as we already track the battery levels for each ship, but real coding is confusing for me at this point.&lt;/P&gt;
 &lt;P&gt;There should be 4 sets of batteries: 1 for UCK_F, 1 for BOS_F, 1 for all other BOSs, and 1 for all KSKs.&lt;/P&gt;
 &lt;P&gt;The pseudocode thingy for each dock should be like this, or maybe not &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
 &lt;PRE&gt;set battery size for UCK_F == 20000
set battery recharge rate from the city grid for UCK_F == 1000
&amp;nbsp;
//this should record in a table that includes the ships name, how much is charged, and the duration of the charge
if ships' state == idle
record ship name
get and record the battery level on idle start
get and record the battery level on idle end
calculate and record the battery level difference
calculate and record duration
&amp;nbsp;
//charge rate control for debug
level difference divided by duration should be equal to the chargeRate of the particular dock (which is set to 4000 for UCK_F at the moment)&lt;/PRE&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;The daily total should just sum up the battery level differences and daily avg. rate just divides it by 24 for each day.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52061-v7.fsm" target="_blank"&gt;v7.fsm&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Thu, 12 May 2022 12:07:09 GMT</pubDate>
    <dc:creator>caner_p</dc:creator>
    <dc:date>2022-05-12T12:07:09Z</dc:date>
    <item>
      <title>Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502862#M17660</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 19.0.0 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi all,&lt;/P&gt;
 &lt;P&gt;I hope you all are fine and healthy during this testing times.&lt;/P&gt;
 &lt;P&gt;I need help on customs coding. In v5, we have completed the battery discharging code thanks to your help. In v6, we are adding the renewable charging component to the model. I throwed in some comments and pseudo codes in custom codes in the model in the hopes of guiding you.&lt;/P&gt;
 &lt;P&gt;What needs to be done is as follows:&lt;/P&gt;
 &lt;P&gt;1) SetRenewableRate is the logic for solar energy charging. It needs to select corresponding value from the global tale RenewableRatesTable, depending on the month and hour and then define the global variable "hourlyRenewableRate". Therefore, &lt;U&gt;ALL&lt;/U&gt; custom codes only in &lt;SPAN style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;&lt;U&gt;SetRenewableRate &lt;/U&gt;&lt;U&gt;l&lt;/U&gt;&lt;/SPAN&gt;&lt;U&gt;ogic&lt;/U&gt; needs fixing. That is all I need.&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52033-v6.fsm" target="_blank"&gt;v6.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P&gt;&lt;S&gt;2) Code below needs to be changed so that it selects a predefined shipPVCapacity &lt;SPAN style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;value&lt;/SPAN&gt; for each ship depeding on the name of the ship.&lt;/S&gt; Defined the values as labels to ships, manually.&lt;/P&gt;
 &lt;PRE&gt;&lt;S&gt;/**Custom Code*/
Object current = param(1);
treenode activity = param(2);
Token token = param(3);
Variant assignTo = param(4);
string labelName = param(5);
treenode processFlow = ownerobject(activity);

TrackedVariable battery = current.labels["Battery"];
battery.rate = dailyDischargeRate*current.dischargeRate + hourlyRenewableRate*shipPVCapacity/1000 ;

//We need to define shipPVCapacity for 4 groups depending on names of transports.
//LC1 to LC13, F1 and F3, F2 and F4, and HSC1-2
//something like this: if Model.name is "LC1" then shipPVCapacity == "750"
//These values needs to be set only once.

return battery.value/current.dischargeRate;&lt;/S&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 May 2022 15:28:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502862#M17660</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-10T15:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502863#M17661</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Since their is no counting/exlucing certain values like with the daily discharge rates, the code is actually quite simply. You just have to read the value from the table, where the current month is the row and the hour is the column (with an offset of one, because hours go from 0-23).&lt;/P&gt;&lt;PRE&gt;// Get month and hour
int month = Model.dateTime.month;
int hour = Model.dateTime.hour;
// Set rate
hourlyRenewableRate = Table("RenewableRatesTable")[month][hour+1];&lt;/PRE&gt;&lt;P&gt;Then will also want to change the delay to wait until the next full hour, instead of day.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652339846581.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510278i3E821A665DA1ABB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652339846581.png" alt="1652339846581.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52046-v61.fsm" target="_blank"&gt;v6(1).fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 May 2022 07:18:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502863#M17661</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-12T07:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502864#M17662</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you, Felix!&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Before I open another question, I need your recommendation on how to proceed on this: I want to track how much power is charged from each dock and how many ships are charging at the same time. Then I think I will not disturb you anymore as modeling will be mostly over &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;There could be a better way but I think I can utilize the loc. labels for this. There are .loc labels given for each ship after it departs to the destination dock e.g. BOS_F, BOS1, BOS2, BOS3..., KSK, KSK1, KSK2, KSK3... etc. When the ship is idle at the dock, it starts charging at a preset rate but I need to see the amount of power drawn from the dock "battery" at the completion of each ship's charge (when it is not at idle anymore) and how many ships are charging at the same time at a dock. I also need the daily total charge is drawn and daily average rates for each dock "batteries".&lt;/P&gt;
 &lt;P&gt;The math is simple as we already track the battery levels for each ship, but real coding is confusing for me at this point.&lt;/P&gt;
 &lt;P&gt;There should be 4 sets of batteries: 1 for UCK_F, 1 for BOS_F, 1 for all other BOSs, and 1 for all KSKs.&lt;/P&gt;
 &lt;P&gt;The pseudocode thingy for each dock should be like this, or maybe not &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
 &lt;PRE&gt;set battery size for UCK_F == 20000
set battery recharge rate from the city grid for UCK_F == 1000
&amp;nbsp;
//this should record in a table that includes the ships name, how much is charged, and the duration of the charge
if ships' state == idle
record ship name
get and record the battery level on idle start
get and record the battery level on idle end
calculate and record the battery level difference
calculate and record duration
&amp;nbsp;
//charge rate control for debug
level difference divided by duration should be equal to the chargeRate of the particular dock (which is set to 4000 for UCK_F at the moment)&lt;/PRE&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;The daily total should just sum up the battery level differences and daily avg. rate just divides it by 24 for each day.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52061-v7.fsm" target="_blank"&gt;v7.fsm&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 May 2022 12:07:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502864#M17662</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-12T12:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502865#M17663</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You don't really need any coding for that if I understand your goal correctly. The token that sets the charge rate when the ship goes idle can create another token that stores the current time and battery level as labels. &lt;/P&gt;&lt;P&gt;This token then waits until a token enters the activity that sets the discharge rate. At that point you can write the info about what ship charged how much over what time and at what location to a global table with the pick option in the custom code activity.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652368718344.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510279iC08334A3FD2D8F18/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652368718344.png" alt="1652368718344.png" /&gt;&lt;/span&gt;You can also split the writing up and add the ship, location and start time immediately. Then fill in the rest of the values later. You only have to store the number of the row that was created (Table(...).numRows).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652368705620.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510281i0C761EDC3C095686/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652368705620.png" alt="1652368705620.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52067-v7-1.fsm" target="_blank"&gt;v7_1.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 May 2022 15:20:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502865#M17663</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-12T15:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502866#M17664</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Thank you Felix! First off, I get lots of console errors on drawing things so that I can not properly see the model file.
 &lt;P&gt;From the SS above, secondly, yes this is part of what I wanted. I need it to show the start and end battery levels and the rate that it was charged. &lt;/P&gt;
 &lt;P&gt;What I mainly wanted was to set a main battery reserve for a dock and track its levels, e.g. BOS dock and any ship that recharges there needs to spend from this reserve. &lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 May 2022 18:25:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502866#M17664</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-12T18:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502867#M17665</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You can add kinetic tracked variables to the docks as well and adjust their rate together with the charge rate of the ships.&lt;/P&gt;&lt;P&gt;I made the charging logic a bit more robust by listening to the unload event instead of the state change to idle, so it doesn't trigger every time the model is stopped. &lt;/P&gt;&lt;P&gt;To get a reference to the dock I take the first three characters of the 'Loc' label and search for the object with that name.&lt;/P&gt;&lt;P&gt;I also added a loop that adjusts the discharge rate when travelling every hour to account for the changed global PV variable.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652428727906.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510282iE463E0552585A1EC/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652428727906.png" alt="1652428727906.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The dock's reserves are reset in the same code block that sets the daily discharge rate.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652428780301.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510283iEEFDE7E9D5464774/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652428780301.png" alt="1652428780301.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52155-v7-2.fsm" target="_blank"&gt;v7-2.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 May 2022 08:00:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502867#M17665</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-13T08:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502868#M17666</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;This looks great.&lt;/P&gt;
 &lt;P&gt;Edit: Ships batteries are still discharging while they are at idle state! This should not happen. &lt;/P&gt;
 &lt;P&gt;Edit 2: Discharging only happens while ships are travelling. When they are at any dock and they are in idle state, the battery levels should stay the same. If they are in a dock with reserve, they should start charging after completing unloading and while they are in idle.&lt;/P&gt;
 &lt;P&gt;Also Edit 2: I'll draw a diagram on how the batteries should operate. I'll update the post.&lt;/P&gt;
 &lt;P&gt;&lt;SPAN style="color: rgb(51, 51, 51); font-family: ;"&gt;"To get a reference to the dock I take the first three characters of the 'Loc' label and search for the object with that name."&lt;/SPAN&gt;&lt;/P&gt;
 &lt;P&gt;&lt;SPAN style="color: rgb(51, 51, 51); font-family: ;"&gt;Could you please seperate reserves (and graphs) for BOS and BOS_F, and UCK and UCK_F? &lt;/SPAN&gt;&lt;/P&gt;
 &lt;P&gt;&lt;SPAN style="color: rgb(51, 51, 51); font-family: ;"&gt;Other than that, you are a master.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 May 2022 08:58:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502868#M17666</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-13T08:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502869#M17667</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;I split UCK and BOS up into two labels. Which one is changed is determined by the first letter of the task executer's name. So don't change the name of the ferries to something that doesn't with "F".&lt;/P&gt;&lt;P&gt;'UCK' (without "F") doesn't currently appear in the statistics because no non-ferries are using it to recharge. If I saw correctly, only very few other ships arrive there and the ones that do continue on immediately.&lt;/P&gt;&lt;P&gt;The discharging when idle was due to a small oversight when copying a decide activity (forgot to remove one part of the condition).&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52150-v7-3.fsm" target="_blank"&gt;v7-3.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 May 2022 12:00:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502869#M17667</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-13T12:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502870#M17668</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you Felix, it seems like it is working now!&lt;/P&gt;
 &lt;P&gt;Sorry for the bleeding eyes and my epic powerpoint skills. I wanted to summarise how the battery logics should work and what is needed next.&lt;/P&gt;
 &lt;P&gt;Ship battery logic:&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="slayt1.jpg"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510284iCF042CFB8CD00BAE/image-size/large?v=v2&amp;amp;px=999" role="button" title="slayt1.jpg" alt="slayt1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;Dock battery logic:&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="slayt2.jpg"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510286i9A334AA5727E9A64/image-size/large?v=v2&amp;amp;px=999" role="button" title="slayt2.jpg" alt="slayt2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;Final steps with the experimenter:&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="slayt3.jpg"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510285i70161ED4EB884674/image-size/large?v=v2&amp;amp;px=999" role="button" title="slayt3.jpg" alt="slayt3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;If you need info on anything or it just doesn't make sense, please do tell.&lt;/P&gt;
 &lt;P&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 May 2022 13:53:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502870#M17668</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-13T13:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502871#M17669</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;One rework later, I think I got the charging/discharging as described. Each rate change is now triggered individually, including the stop when full and resume of PV when not full anymore.&lt;/P&gt;&lt;P&gt;For BOS and UCK it's currently built in the way that both the 'normal' and the 'F' reserve receive half the base and PV rate if both are not at capacity. If only one is charging, it receives the full rate.&lt;/P&gt;&lt;P&gt;The current values I put in as placeholders are too low and the reserves lose charge over multiple days.&lt;/P&gt;&lt;P&gt;If any of the battery/reserve levels fall below 30% the global variable 'fellBelow30' is set to 1. That way you should be able to detect invalid replications in the optimizer.&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52186-v7-4.fsm" target="_blank"&gt;v7-4.fsm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you need any help on the optimizer side, that should probably go into a new question. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 May 2022 16:27:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502871#M17669</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-13T16:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502872#M17670</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello again Felix. Thanks for everything you have done. However there are some misbehaving things:&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="i-wanna-break-free.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510289i631CABC576E87826/image-size/large?v=v2&amp;amp;px=999" role="button" title="i-wanna-break-free.png" alt="i-wanna-break-free.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;- I input a ridiculously high value for dock battery grid charge rate to test it out. BOS_F reserve goes over the rated maxcapacity.&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Image.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1519979iC9BCE29C032A0084/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image.png" alt="Image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;- I know it is outdated now but Dashboard3 looks really weird. It seems like values go over the maxcapacity and it looks like there are no idle states where ships battery value is at max or at the value it entered a dock without charging (there are no horizontal lines indicating this).&lt;/P&gt;
 &lt;P&gt;And a way to adjust all maxCharge capacity and rate values from a single window would be great as a QoL improvement &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Jumping from one custom code to other to change values is my current understanding of the easiest way... Maybe this should go into another question?&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52197-v7-4.fsm" target="_blank"&gt;v7-4.fsm&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 May 2022 20:26:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502872#M17670</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-13T20:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502873#M17671</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Turns out applying rate changes individually and having the reserve value ping-pong between 'not quite full' and 'full' by constantly adding and subtracting the base rate wasn't the best idea. &lt;/P&gt;&lt;P&gt;Not necessarily because of the diverging charge value, but mostly because it is quite inefficient, especially in regards to collecting the statistics.&lt;/P&gt;&lt;P&gt;Instead the reserves now only start to deplete if the total current power draw is larger than the base rate + PV rate. If both 'not_F' and 'F' are drawing power at the same time, the base rate is distributed proportional to the drawn power for each reserve.&lt;/P&gt;&lt;P&gt;The statistics collector for the dashboard3 had to be updated because the activities which change the ship charge rate had changed.&lt;/P&gt;&lt;P&gt;Lastly, I added a table that holds the charge rates for all locations. The respective activity is reading the value corresponding to the ship's current location from it. Similarly you could write all parameters into a table and then assign those values to the respective object labels in the reset trigger of the ships and docks.&lt;/P&gt;&lt;PRE&gt;// Example to set the max reserve value on a dock
// assumes this is placed in the reset trigger
current.maxCharge = Table(...)[row][col];
current.labels["reserve"].as(TrackedVariable).value = current.maxCharge;&lt;/PRE&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52206-v7-6.fsm" target="_blank"&gt;v7-6.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 14 May 2022 11:16:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502873#M17671</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-14T11:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502874#M17672</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you. I couldn't find where "dailyDischargeRate" was in the new code effecting the discharge rate. It should be the multiplier of the battery "dischargeRate"s of all ships for that day. Can you direct me to it?&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="a.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510291iF07D62D54BEFF5B9/image-size/large?v=v2&amp;amp;px=999" role="button" title="a.png" alt="a.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;Now it seems like discharging and battery levels very similar with values of 1, 1.1 and 1.2 for &lt;SPAN style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;dailyDischargeRate&lt;/SPAN&gt;.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 14 May 2022 17:28:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502874#M17672</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-14T17:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502875#M17673</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Good catch! I forgot to add that in the new activities (Adjust rate down/up).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652551748412.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510293i83FA7ACB18EE118C/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652551748412.png" alt="1652551748412.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When the discharge rate is set ('down'), the current factor is written to a label on the ship, so you can check it there.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652551833454.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510294i9EB6700D01E58BE6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652551833454.png" alt="1652551833454.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52208-v7-7.fsm" target="_blank"&gt;v7-7.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 14 May 2022 18:11:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502875#M17673</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-14T18:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502876#M17674</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Could you please take a look at the SetDischargeRate logic? It always produces the same series of values for a month.&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="4-different-runs.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510295i2ED4DDBA86580412/image-size/large?v=v2&amp;amp;px=999" role="button" title="4-different-runs.png" alt="4-different-runs.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;You can even disregard the "maximum days for x value" feature. If there are 5 of 1.2 values in a month, by 0.03 chance, so be it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;Please use this file: &lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52230-v8-base-consumption-trial.fsm" target="_blank"&gt;v8_BASE_CONSUMPTION_trial.fsm&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 May 2022 00:35:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502876#M17674</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-16T00:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502877#M17675</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;To get different results between model runs, you have to deactivate the 'Repeat Random Streams' option.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652682298059.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510296i8783EDAA5B3556D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652682298059.png" alt="1652682298059.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 May 2022 06:25:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502877#M17675</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-16T06:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502878#M17676</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Thank you!
&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 May 2022 17:34:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502878#M17676</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-16T17:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502879#M17677</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi again, &lt;A rel="user" href="https://answers.flexsim.com/users/19365/felixmh.html" nodeid="19365"&gt;@Felix Möhlmann&lt;/A&gt;. I hope your health is good and having a good day. Again, there is one last time I'm in need of your help and guidance. Dock batteries sometimes misbehave.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;-They tend to overcharge:&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="dock-battery-overcharge-problem.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510297iD29E3A87BE00C116/image-size/large?v=v2&amp;amp;px=999" role="button" title="dock-battery-overcharge-problem.png" alt="dock-battery-overcharge-problem.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;-They tend to recharge when no ship is charging (e.g. at night):&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="there-is-no-such-recharge-happening.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510298i50BC5D15AD79CDCB/image-size/large?v=v2&amp;amp;px=999" role="button" title="there-is-no-such-recharge-happening.png" alt="there-is-no-such-recharge-happening.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52462-v9-final.fsm" target="_blank"&gt;v9_Final.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P&gt;Can you please help?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 May 2022 13:17:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502879#M17677</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-05-19T13:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502880#M17678</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;The smaller peaks you are seeing in the first screenshot are graphical artifacts that happen when there are points that form a triangle are very close together on the x-axis. The actul data point is at the cap but the line sort of 'overshoots' because the triangle that forms the peak ends in a very acute angle.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1652979079535.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510299i90227C7ECE0A545B/image-size/large?v=v2&amp;amp;px=999" role="button" title="1652979079535.png" alt="1652979079535.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;These peaks will appear/disappear when the interval that the graph displays changes. You can set the graph to use the 'time window' on the x-axis and play with the interval to see this effect.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="visualartifact.gif"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1510303i76DD11A0C59159BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="visualartifact.gif" alt="visualartifact.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The larger rise above the max capacity and the recharging at night were seemingly caused by a &lt;A href="https://en.wikipedia.org/wiki/Floating-point_error_mitigation"&gt;floating point error&lt;/A&gt;, where 'reserve &amp;lt; maxCapacity' is evaluated as true.&lt;/P&gt;&lt;P&gt;I changed those checks to 'reserve &amp;lt; maxCapacity - 0.001' to prevent this.&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52497-v9-final-fm.fsm" target="_blank"&gt;v9-final-fm.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 May 2022 16:52:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502880#M17678</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2022-05-19T16:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help on custom coding for battery charging</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502881#M17679</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi there Felix. I hope you had a lovely weekend. I know that I did not give you any rest, so please accept my apologies.&lt;/P&gt;
 &lt;P&gt;The "SetDischargeRate" logic is not randomly generating the "dischargeFactor" value. In fact, it always produces the same series. Please see the results for 1 month period.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;TABLE border="0" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;width:48pt;"&gt;Col 1&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;Col 1&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;Col 1&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;Col 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,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="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1,2&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Could you please alter the custom code so that it really randomizes?&lt;/P&gt;
 &lt;P&gt;If you want, you can use the ratio and probability table below (For January, there is 0.55 &lt;SPAN style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;probability&lt;/SPAN&gt; for &lt;SPAN style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;dischargeFactor&lt;/SPAN&gt; to be 1 for that day, 0.42 probability for &lt;SPAN style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;dischargeFactor&lt;/SPAN&gt; to be 1.1 for that day and 0.03 probability for &lt;SPAN style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;dischargeFactor&lt;/SPAN&gt; to be 1.2 for that day):&lt;/P&gt;
 &lt;TABLE border="0" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;width:48pt;"&gt;1&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;0,55&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;1,1&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;0,42&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;1,2&lt;/TD&gt;&lt;TD style="width:48pt;"&gt;0,03&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;0,39&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;0,48&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;TD&gt;0,03&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;0,39&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;0,58&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;TD&gt;0,03&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;0,35&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;0,58&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;TD&gt;0,03&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;0,23&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;0,74&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;TD&gt;0,03&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&gt;0,06&lt;/TD&gt;&lt;TD&gt;1,1&lt;/TD&gt;&lt;TD&gt;0,81&lt;/TD&gt;&lt;TD&gt;1,2&lt;/TD&gt;&lt;TD&gt;0,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="height:15.0pt;"&gt;1&lt;/TD&gt;&lt;TD&g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&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;For example, it does not matter if there are 3 consecutive days with 1.2 value or not. It is just chance. However, it just cannot have the exact same series the next time it runs.&lt;/P&gt;
 &lt;P&gt;Please use this file: &lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/52236-v8-base-consumption-trial.fsm" target="_blank"&gt;v8_BASE_CONSUMPTION_trial.fsm&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 Jun 2022 10:57:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/help-on-custom-coding-for-battery-charging/m-p/13502881#M17679</guid>
      <dc:creator>caner_p</dc:creator>
      <dc:date>2022-06-01T10:57:32Z</dc:date>
    </item>
  </channel>
</rss>

