-
Notifications
You must be signed in to change notification settings - Fork 11
Creating Demos
Demos are intended as a starting point for new users of the Campus Energy Modeling library. Therefore, all demos should have a standard structure, should be easy to use, and should lend themselves to modification.
All demos should adhere to the structure outlined below, in which mydemo serves as an example demo name. (Substitute the name of your demo wherever you see mydemo.)
- Place all files for the demo apart from test data within a single, uniquely named folder (
mydemo) under theDemodirectory. - Include a Simulink model
mydemo.mdl. - Include a README file
README.txt. - If the demo requires initialization, include an initialization script
mydemo_init.m. - If the demo requires test data, include it in plain text format in the
/Test/datafolder of the Campus Energy Modeling library rather than in themydemofolder. See Testing for details. - Place any additional files required by the demo (for instance, EnergyPlus models) in the
mydemofolder or a dedicated subfolder.
Please conform to the following recommendations for the demo model, initialization script, and documentation.
The demo should be simple, clean, elegant, organized, and easy to understand under casual observation.
- Ensure a clean layout; avoid overlapping or confusing signal paths.
- Clearly label Simulink blocks intended for user interaction. Examples: Configuration switches, setpoints.
- Use color coding to enhance model readability:
- Color code From and Goto blocks according to their associated signals, matching colors to the Campus Energy Modeling library subcategories.
- Color outputs and scopes gray to set them apart.
- Use red text to identify blocks intended for user interaction.
- Provide labels and contextual notes as required to understand the layout of the model.
Existing demos provide concrete examples of these style guidelines.
Each demo that requires initialization should include a single initialization script named mydemo_init.m, in which mydemo is the name of the demo. This initialization script should conform to the following template:
%% [Name of Demo] Demo - Initialization Script
%
% Provide a brief summary of the function of the initialization script in
% relationship to the demo. Include guidance for user settings, if needed.
%
% Multiple descriptive paragraphs are fine.
%
% COMMENTS:
% 1. Reserve any extensive comments for the comments section.
%
% 2. Number comments sequentially.
%
% 3. The COMMENTS section is optional.
%% User Settings
% If the demo has any user-configurable settings, this section is required.
% Allow users to input settings in the format:
setting = [value];
% Provide brief guidance for each setting
%% Other Sections
% Run all code to initialize the demo here.
% All remaining code sections in the script must not require user input.The initialization script should be easy to understand and modify. Comments within the initialization script should pertain specifically to the initialization of the demo; place more general comments in the demo's README.txt.
Individual demos are documented in three places:
- In the demo list under Demos
- In the
README.txtfile for each demo - In the demo initialization script (if any)
To document a new demo, please add it to the demo list and create README.txt according to the guidelines in Writing Documentation. README.txt should contain step-by-step instructions for initializing and executing the demo. These instructions should follow the general pattern:
Instructions:
1. Open MATLAB and set the working directory to the folder that contains this README file.
2. Open the script 'mydemo_init.m'.
3. Review the user settings in 'mydemo_init.m' and modify as desired.
4. Run 'mydemo_init.m' to initialize the demo.
5. Open and run the Simulink model 'mydemo.mdl' and view the results.
Whenever possible, avoid burdening the user with initialization requirements beyond editing and running the initialization script. Any detailed instructions or comments related to demo initialization should be included within the initialization script itself.
Prior to release, demos should be tested using the following procedure:
- Commit (or stash) any uncommitted changes.
- Back up the
Demodirectory manually to another location on disk. - Delete the
Demodirectory from the project. - Reset the project using
git reset --hard. This restores the exact version of theDemodirectory last committed to Git. - Run the demo initialization script.
- Run the demo simulation.
Step 2 is a precaution in case your demos contain inadvertently uncommitted scripts or data; if you are sure this is not the case you may skip it. Steps 5 and 6 ensure that the demo runs cleanly "out of the box", that is, freshly loaded from a Campus Energy Modeling release.
If the test uncovers any errors, such as missing data files or sections of the initialization script which do not operate properly, fix these errors, commit, and re-run the test.