WSModelObject
An object that exist in the database tree such as model groups, networks, selection lists, and stored queries.
Methods that return a WSModelObject
may return a derived class, for example a WSNumbatNetworkObject for network types, or WSSimObject for simulations.
Methods:
- != (Does Not Equal)
- == (Equals)
- [] (Get Field)
- []= (Set Field)
- bulk_delete
- children
- comment
- comment= (Set)
- compare_demand_diagram
- copy_here
- deletable?
- delete
- export_demand_diagram
- find_child_model_object
- gmr_clear_test_cases
- gmr_export_test_cases
- gmr_import_test_cases
- id
- import_demand_diagram
- import_synergi
- modified_by
- name
- name= (Set)
- new_model_object
- open
- parent_id
- parent_type
- path
- status
- status= (Set)
- type
!= (Does Not Equal)
#!=(other_mo) ⇒ Boolean
EXCHANGE
, UI
Checks if this model object is not the same as another model object (inequality check).
== (Equals)
#==(other_mo) ⇒ Boolean
EXCHANGE
, UI
Checks if this model object is the same as another model object (equality check).
[] (Get Field)
#[(field)] ⇒ Any
EXCHANGE
, UI
Returns the value of a field.
[]= (Set Field)
#[(field)]=(value) ⇒ void
EXCHANGE
, UI
Sets the value of a field.
Parameters
Name | Type(s) | Description |
---|---|---|
field | String | Name of the field. |
value | Any | Value to set, if this field references a database object the value can be the id, scripting path, or a wsmodelobject of the correct type. |
bulk_delete
#bulk_delete ⇒ void
EXCHANGE
, UI
Permanently deletes the object and all of its children, skipping the recycle bin.
This method works even if the object has children or is used in a simulation, which does not follow the user interface convention. For a safer version of this method, see #delete.
children
#children ⇒ WSModelObjectCollection
EXCHANGE
, UI
Returns the children of the object.
Parameters
Name | Type(s) | Description |
---|---|---|
Return | WSModelObjectCollection |
comment
#comment ⇒ String
EXCHANGE
Returns the comment, a.k.a the description in the user interface.
Parameters
Name | Type(s) | Description |
---|---|---|
Return | String |
comment= (Set)
#comment=(text) ⇒ void
EXCHANGE
Sets the comment, a.k.a the description in the user interface.
Parameters
Name | Type(s) | Description |
---|---|---|
comment | String | The comment text. |
compare_demand_diagram
#compare_demand_diagram(other) ⇒ Boolean
EXCHANGE
Checks if two demand diagrams are identical. This WSModelObject
and the object to compare must be a demand diagram.
ddg = db.model_object_from_type_and_id('Demand Diagram', 48)
other_ddg = db.model_object_from_type_and_id('Demand Diagram', 213)
compare = ddg.compare_demand_diagram(other_ddg)
puts compare ? 'Demand Diagrams are the same!' : 'Demand Diagrams are different!'
Parameters
Name | Type(s) | Description |
---|---|---|
other | WSModelObject | The other demand diagram, must be a demand diagram. |
Return | Boolean | If the demand diagrams are identical, false if they are not. |
copy_here
#copy_here(object, copy_sims, copy_ground_models) ⇒ WSModelObject
EXCHANGE
, UI
Copies a model object and any children as a child of this object, returning the new model object. The model object being copied could be from the same database, or another database such as a transportable database.
Parameters
Name | Type(s) | Description |
---|---|---|
object | WSModelObject | The model object to copy. |
copy_results | Boolean | Whether to copy simulation results, if the model object (or it's children) have simulations with results. |
copy_ground_models | Boolean | Whether to copy ground models. |
Return | WSModelObject | The newly copied object in this database. |
deletable?
#deletable? ⇒ Boolean
EXCHANGE
Whether this model object can be deleted using the #delete
method, which follows the user interface rules: has no children, and is not used in a simulation.
Parameters
Name | Type(s) | Description |
---|---|---|
Return | Boolean |
delete
#delete ⇒ void
EXCHANGE
, UI
Deletes the object, provided it meets the user interface rules: has no children, and is not used in a simulation.
This is a safer alternative to the #bulk_delete method, which ignores these rules.
export_demand_diagram
#export_demand_diagram(filename) ⇒ void
EXCHANGE
Exports the demand diagram to a file. The file extension dictates the data format, which can be ddg
, csv
, or json
.
ddg.export_demand_diagram('C:/Badger/demand_diagram.json')
This WSModelObject
must be a demand diagram.
Parameters
Name | Type(s) | Description |
---|---|---|
filename | String | Destination filepath including the file extension. |
find_child_model_object
#find_child_model_object(type, name) ⇒ WSModelObject?
EXCHANGE
, UI
Finds a child model object of a given type and name.
Parameters
Name | Type(s) | Description |
---|---|---|
type | String | The type of the object. |
name | String | The name of the object. |
gmr_clear_test_cases
#gmr_clear_test_cases ⇒ void
EXCHANGE
, UI
Clears test cases on this GMR object.
Examples
gmr_config = db.model_object_from_type_and_id('Gen Multi Run Cfg', 1309)
gmr_config_import.gmr_clear_test_cases
gmr_export_test_cases
#gmr_export_test_cases(file_name) ⇒ void
EXCHANGE
, UI
Exports all test cases to CSV.
Examples
gmr_config = db.model_object_from_type_and_id('Gen Multi Run Cfg', 1309)
gmr_config.gmr_export_test_cases("D:/CSV/Testcases.csv")
Parameters
Name | Type(s) | Description |
---|---|---|
file_name | String | Path to the file. |
gmr_import_test_cases
#gmr_export_test_cases(file_name) ⇒ void
EXCHANGE
, UI
Imports new test cases from CSV, for example from #gmr_export_test_cases.
Examples
gmr_config = db.model_object_from_type_and_id('Gen Multi Run Cfg', 1309)
gmr_config_import.gmr_import_test_cases("D:\\CSV\\testcases.csv")
Parameters
Name | Type(s) | Description |
---|---|---|
file_name | String | Path to the file. |
id
#id ⇒ Integer
EXCHANGE
, UI
Returns the ID of this model object.
import_demand_diagram
#import_demand_diagram(filename) ⇒ WSModelObject
EXCHANGE
Imports a new demand diagram from a file. The new demand diagram will use the imported file name.
This WSModelObject
must be a demand diagram group.
Examples
ddg = ddg_group.import_demand_diagram('C:/Badger/demand_diagram.json')
ddg.name = 'My New Demand Diagram'
Parameters
Name | Type(s) | Description |
---|---|---|
filename | String | Filepath to the demand diagram, including the file extension. the file extension determines the expected input format (ddg , csv , or json ). |
Return | WSModelObject |
import_synergi
#import_synergi(file, network_name, control_name, ddg_group_name, selection_list_group_name, run_group_name, html_file_name, use_ace) ⇒ void
EXCHANGE
Import a Synergi model, equivalent to the import feature in the user interface.
Parameters
Name | Type(s) | Description |
---|---|---|
filename | String | File path to the synergi model (.mdb) that will be imported. |
network_name | String | Name for the new network. |
control_name | String | Name for the new control. |
ddg_group_name | String | Name for the new demand diagram group. |
selection_list_name | String | Name for the new selection list group. |
run_group_name | String | Name for the new run group. |
html_file_name | String | File path for the html file where the import log should be written. |
use_ace | Boolean | Boolean indicating if ace (access database engine) should be used for the import, which must be installed. this is the only supported method for 64bit thales and autodesk software versions. if false the application will use jet database engine which is only supported on 32 bit (thales licensing). |
modified_by
#modified_by ⇒ String
EXCHANGE
, UI
Returns the username which last modified the object. This may be different from the latest commit of a version controlled network.
name
#name ⇒ String
EXCHANGE
, UI
Returns the name of this object.
name= (Set)
#name=(new_name) ⇒ void
EXCHANGE
, UI
Sets the name of this object.
Parameters
Name | Type(s) | Description |
---|---|---|
new_name | String |
new_model_object
#new_model_object(type, name) ⇒ WSModelObject
EXCHANGE
, UI
Creates a new model object as a child of this object - the type must be valid for this object.
Scripts that are running in the user interface are unable to create most types of model objects, the only exceptions being Selection Lists and Selection List Groups. The full functionality of this method is only available in Exchange.
Runs cannot be created using this method, they are created using a WSRunScheduler object.
Parameters
Name | Type(s) | Description |
---|---|---|
type | String | Type of the new model object. |
name | String | Name of the new model object. |
Exceptions
- unrecognised type - if the type is not a valid scripting type
- sims cannot be created directly - if an attempt is made to create a sim
- invalid child type for this object - if the new type may not be a child of this object type
- name already in use - if the name is in use by another model object (that is also a child of this object), or globally if this is a version controlled type with a standalone database
- licence and/or permissions do not permit creation of a child of this type for this object - if this type of object cannot be created for licensing and/or permissions reasons
- unable to create object - if the call fails for some other reason
open
#open ⇒ WSModelObject
EXCHANGE
, UI
Only available for model objects of a network type or sim.
Opens the network and returns a WSOpenNetwork object. When this method is called on a sim, the network and results are opened. An exception will be thrown if the simulation did not succeed or the results are inaccessible.
Note that when you open the results of a simulation:
- The network is opened as read only
- The current scenario is set to the scenario used for the simulation
- The current scenario cannot be changed
- As with the behaviour in the UI of the software, the network with the results loaded has a current timestep. The results start by being opened at the first timestep (timestep 0) unless there are only maximum results in which case they are opened as the maximum results timestep.
Parameters
Name | Type(s) | Description |
---|---|---|
Return | WSModelObject |
parent_id
#parent_id ⇒ Integer
EXCHANGE
, UI
Returns the ID of this object's parent. This will be 0 if the object is in the root of the database.
parent_type
#parent_type ⇒ String
EXCHANGE
, UI
Returns the type of this object's parent. This will be 'Master Database' if the object is in the root of the database.
path
#path ⇒ String
EXCHANGE
, UI
Returns the scripting path of this object.
status
#status ⇒ Integer
EXCHANGE
Gets the value of the status field.
Parameters
Name | Type(s) | Description |
---|---|---|
Return | Integer |
status= (Set)
#status=(i) ⇒ void
EXCHANGE
Sets the value of the status field. This field is not visible in the user interface and can be used for any purpose.
An example use case is for automated tasks such as model building, where you can store the outcome against the model object so that other scripts can read it. In this use case, the integers would map to a known status code which you define e.g.
- 0 : Success
- 1 : Warnings
- 2 : Error
Parameters
Name | Type(s) | Description |
---|---|---|
i | Integer | The status code. |
type
#type ⇒ String
EXCHANGE
, UI
Returns the type of this model object.