====== Snapshot ====== The snapshot block takes a snapshot of a given expression when a [[Discrete_Event|discrete events]] is triggered. In versions prior to Ecolego 6, this functionality was incorporated in the recorder block. When creating a snapshot block, you must specify either the name of the object to monitor, or an expression to monitor. This is called the “Target expression”. You also select a [[Discrete_Event|discrete events]] which will trigger the snapshot. ===== Creating a snapshot block ===== From the [[Projects_window|Projects window]] * Expand the Project to which you wish to add the snapshot by clicking the + symbol next to it. Right-click on ‘Blocks’, or a [[Sub-system|sub-system]] in ‘Blocks’, and select **Snapshot** from the pop-up menu. From the [[Matrix_window|Matrix window]] * Right click an empty diagonal cell of the matrix and select **Snapshot** from the the pop-up menu. From the [[Blocks_window|Blocks window]] * Place the mouse anywhere over the area of this window and right-click on it. Select **New | Snapshot** from the pop-up menu, //or// * In the title bar, select **Snapshot** from the **Type** drop-down list and click on the {{:New24.png|New}} button. ===== Editing a snapshot block ===== |Note|Most block properties can be edited directly in the [[Blocks_window|Blocks window]].| The block editor is shown by right-clicking the block in a window and selecting **Edit**. In the [[Blocks_window|Blocks window]], you can also show the block editor by selecting the block and clicking the {{:Edit24.png|Edit}} button, or by double-clicking the right-most “validation” column of the block. The block editor has three tabs: ==== Properties ==== This page lets you edit basic properties such as name, sub-system and base unit. See [[Editing_properties|editing properties]] for more information. ==== Appearance ==== This page lets you edit the visual properties of the block in the [[Matrix_window|matrix window]] and [[Graph_window|graph window]]. See [[Editing_appearance|editing appearance]] for more information. ==== Values ==== **Dimension** - You can specify the dimension of the block by using the **Type** drop down list. Depending on the dimension the index drop down lists are activated. **Data** - The data table let you specify index specific properties like target expression. * **//Indices//** - For blocks that are non-scalar, the first columns will specify indices from the [[Index_list|index lists]]. This allows you to specify different expressions for different indices. * **Target expression** - Enter either just the ID of an object to monitor, or enter a full expression. * **Event** - Select a [[Discrete_Event|discrete event]] which will trigger the snapshot. The value of the block will then be set to the value of target expression at the time of the event occurred. * **Initial value** - Enter an expression for the initial value of the block, until the first snapshot has been taken. * **Information** - By using the [[Table_control_button|Table control button]] you can display more columns that will help you document your model. ===== Example: Min/Max, Snapshot ===== Consider a model which simulates the financial transactions between yourself and your bank. A block named //balance// contains the current balance of your accounts. You wish to find out the maximum amount of money on your account over the month, and present this value by month. To achieve this we need a [[Discrete_Event|discrete event]] which at the beginning of each month will - Reset the Min/Max block. - Take a snapshot of the Min/Max block. The reason that we use a snapshot is because the value of the Min/Max block will change over the month as money are deposited or withdrawn from your accounts. Assuming that the time unit is years, create a [[Discrete_Event|discrete event]] named Event_new_month with the following values: ^Property ^Value ^ |Left expression |time/12-round(time/12)| |Direction |-> | |Right expression|0 | Create a min/max block named //balance_max//, with the **operation** of Maximum. Give it the following values: ^Property ^Value ^ |Target expression|balance | |Reset |Event_new_month| Finally create a snapshot block with the following values: ^Property ^Value ^ |Target expression|balance_max | |Event |Event_new_month| ===== See also ===== * [[Block|Blocks]] * The [[Blocks_window|Blocks window]] * The [[Matrix_window|Matrix window]] * The [[Graph_window|Graph window]]