Stormworks: Build and Rescue

Stormworks: Build and Rescue

评价数不足
CSV Logger Tutorial
由 Razor 制作
This tutorial covers how to use the CSV Logger micro-controller by Lupus the Canine.

What is CSV and how might it relate to Stormworks?
CSV stands for Comma-separated values [en.wikipedia.org]. If you want to collect time-series in-game data (such as engine rps, temperature, etc.) from Stormworks, this is an ideal way to format it. Most spreadsheet programs can read CSV data and there are many applications that can plot the data so that it can be analyzed visually.

Why use CSV when I can just look at data in-game?
There are many ways to go about storing & analyzing data in-game. However, using data in CSV format with external software can provide access to much more powerful and efficient data analysis tools. It's also a handy way to create graphics about your data.
   
奖励
收藏
已收藏
取消收藏
Summarized Instructions
If you don't want to read the entire guide, then this brief list of steps may suffice:
  1. Subscribe to CSV Logger by Lupus the Canine
  2. Follow the link in the CSV Logger's workshop description to GitHub and download StormLogger.exe
  3. In Stormworks, load the CSV Logger micro-controller into the creation you want to use it with.
  4. Connect the video output of the CSV Logger to a powered 2x2 screen, a push & toggle button to its "Reconnect" & "Transmit" inputs respectively, and your composite data that you wish to log to the "Data" composite input.
  5. Select the CSV Logger micro-controller, then enable & name the desired channels
  6. While Stormworks is running, go into Windows and run StormLogger.exe
  7. Spawn your creation and ensure StormLogger.exe's command prompt and the 2x2 screen in Stormworks say "Connected". If not, press the "Connect" push button in-game.
  8. When you are ready to collect data, press the "Transmit" toggle button in-game, ensure that the 2x2 screen says "transmitting" and that the StormLogger.exe window shows the name of the .csv file it created and the names of all the variables it is receiving.
  9. Conduct your tests as needed. When finished, press the "Transmit" toggle button again to stop logging data. Ensure that StormLogger.exe says "END"
  10. The .csv file that was created will be at the same location as StormLogger.exe at the time that it ran and should now be ready for use.
Step-by-step example with pictures
First, Subscribe to CSV Logger by Lupus the Canine. Then, follow the link in the CSV Logger's workshop description to GitHub and click on the latest release, as shown in the following image:

After clicking on the latest release, you should see a small list of files. Click on StormLogger.exe to download it. Your browser might advise against downloading it; however, I have not had any problems with it.

Next, ensure that you place the StormLogger.exe file where you can find it easily. Note that when it creates .csv files, it will place them in the same directory that it is located.




Now, subscribe to this CSV Logger Example that I made. It's basically a small engine test stand that will allow us to demonstrate the CSV Logger. Load it into your vehicle editor. This image shows its layout:




Note all of the logic connections for the CSV Logger micro-controller, which is painted blue in color. It has a push button for the "Reconnect" input, a toggle button for the "Transmit" input, a video output connected to a 2x2 screen, and a composite data input. The data that we'll be sending to be logged will come from the 2x2 micro-controller that is painted orange. Here you can see the composite connection:




Next, select the blue CSV Logger microcontroller. You should see a list of options appear on the left, like this:



The options in the above image can be described as follows. "Data format" is custom, human readable short, etc. "Sampling frequency Hz" is how many times per second that the data will be logged. In this case, it is 60 times per second. The game's tick rate is 60 per second, so I would advise choosing a number equal to or less than 60. Often, a lower tick rate may suffice and even once per second might be useful in some cases. "Custom format string" is a format specifier related to programming syntax, and %.10g basically means the data is formatted into a floating point number with a maximum of ten decimal places of precision. In most cases, you can probably leave this alone. After that option are the data channels - be sure to enable and name the ones you want to record.

In this example, we have four channels enabled. We named them EngineRPS, GenOutput, FuelCons, and GenOutPerFuel respectively. I chose to leave no spaces in the names so that the variables can be used more easily with 3rd party software functions as we'll see later. GenOutPerFuel is simply (Generator Output / Fuel Consumption rate in L/s).

Our next step will be to, while Stormworks is still running, go into windows and run StormLogger.exe. It should look something like this:



Next, spawn in the CSV Logger Example engine test stand. If StormLogger.exe is running when you spawn it, it should automatically connect. You can also choose to spawn your creation first, then start the .exe after, you'll just need to press the reconnect button. Anyway, it should look like this:



As you can see, it says connected both on the in-game screen and in the .exe window, and it should look like this:



Now, press the transmit button as shown here:



As soon as the previous step is done, StormLogger.exe will create the .csv file and begin receiving data from the variables. The command prompt window should look like this:



We're ready to start conducting our test. So, we'll go over to the engine controls and use the ignition to start the engine. Then we'll fully engage the clutch. Next we'll max out the throttle. We'll let it run that way for about ten seconds so that we can get good data with a 1:1 gear ratio. Next, we'll press the gear shift button. This will change the gearbox to a 2:1 setting and cause the generator to spin twice as fast as the engine crankshaft. Let the system run for at least ten seconds again so that the values can stabilize and we get a good amount of data. You will notice that the engine slows down a lot when you shift to the higher gear, but the bright side is that our generator output to fuel use ratio has improved as we'll see when we look at our data.

We're done collecting data for now, so we'll press the Transmit toggle button again to stop transmitting data. The .exe should say "END" as you see here:



Congratulations! You now have a .csv file loaded down with tons of data that you can use with other programs. It is compatible with excel, but be warned that you'll likely be dealing with thousands of lines of raw data. I recommend using 3rd party software of some kind to help organize and visualize the data. You can go into the MicroSoft store and find many free programs that do just that. Just search "csv plotter" for example. There are also web-based csv plotters out there. If you would like to see an example usage of a 3rd party software that I personally recommend to make use of the .csv file, then proceed to the next section.
Example 3rd party software usage
In this example, we will use Flow CSV Viewer 1.1.8 which you can find and download for free on the Microsoft Store. I like it for many reasons, including that it orients time on the x axis by default, which corresponds to the way in which we acquired our data in Stormworks. It is pretty easy to use, just open the .csv file that you made and you'll likely get something like this:



As you can see, in my example some variables are separated and some are together. This is handy when the numbers differ greatly and varied scales are needed to visualize the values more effectively. Note that you can drag the variables around in the list on the left to reorder or regroup them. You can also hide variables, change their color, and so on.

If we look at any of the graphs, we can see all the events as they happened over time. At 60 Hz sample rate, we recorded about 11000 game ticks, which divided by 60 is about 183 seconds. We can see the pause before the ignition, the fluctuations right after ignition, the clutch engagement, the EngineRPS increase resulting from throttle increase, and the gear shift. Note that in the GenOutPerFuel variable, we see two plateaus - 1:1 gear ratio around the x=7000 mark and 2:1 gear setting around the x=9000 mark. Interestingly, we get slightly better generator output per fuel used when we are using the higher gear setting. In fact, if we go up to the tool bar and pick our Select tool, we can then select the region of the graph where we were using the 2:1 gear setting so that we can get more precise data about it. Here's what we see:



At the bottom we see that there is a lot of info about the region we selected, and the average value of it is about 510. Now we have a value that we can compare with other set ups. Granted, one could simply set up a display in-game to show output per fuel, but this was for demonstration purposes only.

Thanks for reading my guide! I hope it helps you as an engineering and learning tool. Credit to Uran Wind for his ZE Modular Engine Controller which I used on the engine test stand example. I also give thanks to Lupus the Canine for his CSV Logger and for his permission to make this guide.