Siemens Industrial PCs (IPC) are a great option for projects that require data logging and storage within a Windows operating system.
A project I worked on recently required us to do exactly that. We needed to log alarms and audit trails, but we also wanted a completely immersive experience for the customer. This meant that we needed to keep track of storage space within WinCC Runtime and warn the user when the free storage space in Windows was reduced. With a large amount of data logging, it is likely that disk space would fill up quickly.
This solution was completely possible in WinCC Advanced/Professional using VBScripts and the GetDrive function.
Step 1. Setting up the script
Since we are using VBScripts for this solution, we will create a VBScript in the HMI section of the project. It is good to note that the HMI Runtime application is within a Siemens IPC277E 15” MultiTouch as an example IPC.
Step 2. Creating the FileSystemObject
As mentioned before, we are going to use the GetDrive function. This will be used to get our drive’s information into our VBScript. To store the information from the GetDrive function, we must use an object variable. You can use the Dim statement to create and allocate storage space for variables and then use the CreateObject function to create the correct variable structure.
Step 3. The GetDrive Function
Now that we have selected our drive in with our file system object variable, we can use our GetDrive function to store information about the IPC in this variable.
Step 4. Variable Restrictions
Free space is the quantity needed for this application. With our drive variable “d” containing information about our drive, we can use “d.FreeSpace” to receive the amount of free space on our drive in bytes. We divided our result by 1024^2 to display our free space in megabytes. If you’d like to view your free space as a percentage, you can get the total space of your drive as well. Make sure to add variables for these values if needed.
Step 6. Potential Actions
You can now use the disk space variable with the updated storage information for whatever you need. The example below shows a system alarm stating how much storage is left whenever this script is run. Another good example is triggering HMI tags with the script depending on the result.
Step 7. Setting the Script Triggers
For our application, we set a scheduled task on the script to periodically check the disk space. The benefit of this is that the operator will be able to see the disk space warning without having to remember to check it.
We also wanted a manual way to check the disk space for our application. One easy way to do this is to add the script to a push button. A common button to add it to would be a button in a settings page. You can also attach it to another process like data logging.
Once these steps are completed, you will have an immersive disk space monitoring solution with automatic and manual checks for disk space. This is another useful tool in the toolbox for engineers working with Siemens IPCs.
Full Script:
Learn more about DMC’s WinCC programming expertise and contact us for your next project.