PyANGKernel.GKColumn¶
- class GKColumn¶
Attribute for a type.
Details
The
GKColumnhold information for one attribute of a type. It keeps the attribute type (integer, double, string,…) the name (either internal and external) and how to manage the it when an instance of a class that uses this attribute is created (store type).<H2>Types</H2>
An attribute instance is, in fact, a QVariant or QVariant derivate, so it can hold the same value types as QVariant. Aimsun adds some extra types to manage the following information:
_GKObject: An integer holding the unique identifier of an object. The object can be read with:GKModel *model; GKObject *object; ... object = model->getCatalog().find( objValue );
_GKEnum: Defines a set of symbolic constants with ordered numeric values ala C enum types. Each numeric value (stored as an integer) can have a string (QString) associated. I this case the string value will be used instead of the numeric value when showing the value to the user. The relevant methods are: -setEnumString: set the string for a numeric value -getEnumString: get the string from a numeric value
It also adds the posibility (in C++) to set a function to calculate the value of this column for a given object. See GKColumn::setCFunction.
<H2>Attribute Names</H2>
An attribute has two names, one internal accessible with
getNameandsetNameand one external accessible withgetExternalNameandsetExternalName. Both names are set by the user when the attribute is created (using the GKType::addColumn method).The internal name is a unique name among all the names for the attributes, is up to the user to guaranty that the name is unique (adding the as a prefix the name of the class for this attribute is, usually, enough).
The external name is the name of the attribute that will be presented to the user. It do not need to be unique and can change during the lifetime of the attribute (and can be translated).
<H2>Attribute Type</H2>
See
GKTypefor information on Attribute Type.<H2>Groups</H2>
Related attributes can be grouped using
setGroupName. This information will be use by several editors to show related attributes together. The group (Optional) is identified by its name. An external name is used to give a human readable name usingsetExternalGroupName.To add extra flexibility the group is stored in a string list in where each element is a subgroup of the previous one. Example: { Micro, Zones }
<H2>Locale Conversion</H2>
A
GKColumncan be marked as one of the following types viasetConversionandgetConversion: - Speed (km/s) - Speed MS (m/s) - Distance (m) - Acceleration (m/s^2) - Weight (kg) - Density (veh/km)This information is used by the generic editors to show the value of an attribute using the locale set by the user (since all the data in Aimsun Next is stored in metric units).
Note that only the generic editors and not the developer defined editors will automatically translate the data to (and from) the appropriate locale. The GKObject::setUserData only accepts metric units and the GKObject::getUserData returns only data in metric units regardless the information set via
GKColumn:setConversion.By default an attribute do not bellow to any of these types.
<H2>Extra Information</H2>
An attribute also hold the following information: - a description: a string to describe the attribute to the user. Its optional. - editable: is the value of this attribute in each object that uses it read only? True by default. - dynamic: can the value of the attribute change with the time? Note that an editable attribute can be changed by the user at any moment but this do not mean that is dynamic. Dynamic refers to attributes that changes its value due to external changes and not due to an user direct change. Example of this type of attributes are time series that return a value based on the current time.
Synopsis¶
Methods¶
def
__init__()def
anyEnumString()def
getColumnType()def
getContent()def
getContentMain()def
getContents()def
getConversion()def
getDescription()def
getEnumString()def
getEnumStrings()def
getGroupName()def
getId()def
getName()def
getObjectType()def
getOrigin()def
getOriginator()def
getPrecision()def
getPythonCode()def
getRealColumn()def
getStoreType()def
getType()def
getValueToGui()def
isByArea()def
isDynamic()def
isEditable()def
isGEHColumn()def
isOverridable()def
isReal()def
setByArea()def
setColumnType()def
setContents()def
setConversion()def
setDescription()def
setDynamic()def
setEditable()def
setEnumString()def
setGroupName()def
setId()def
setIsGEHColumn()def
setName()def
setObjectType()def
setOrigin()def
setOverridable()def
setPrecision()def
setPythonCode()def
setRealColumn()def
setStoreType()def
setType()
Static functions¶
def
getOriginName()def
getOriginator()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- class Type¶
Same as QVariant types plus the
GKObjectpointer,GKTimeSerie, GKEnum andGKTimeDurationThey are in different order so you cannot do a direct cast
- class GKColumnType¶
There are four types of attributes: - internal (eInternal): exists in C++ and the user just make it accessible. - external (eExternal): doesn’t exist in C++. Aimsun Next will provide storage in memory and in disk for it. Be aware about using Void column type, the store/restore behavedue having a specific modification of the dataStream. - external temporary (eExternalTemporary): doesn’t exist in C++. Aimsun Next will provide storage in memory (it will not be saved in disk). - python (ePython): a python function that returns the value of the attribute. - C (eC): a C function that returns the value of the attribute.
When using Python the function must be:
def eval_attr( object ): # compute the value return res
“object” is the object that will be evaluated. “res” is the returned value which type must the one defined in
setColumnType. The current implementation only supports: String (QString), Int,UInt, Bool, Double, Date (QDate)When using C the function must be (if a int is returned):
int eval_attr( GKObject * object ) { int res = 0; // compute the value return res; }
As in Python, “object” is the object that will be evaluated. “res” is the returned value which type must the one defined in
setColumnType. The current implementation only support: String (QString), Int (int),UInt(unsigned int), Bool (bool), Double (double), Date (QDate), Time Series (double)
- class GKColumnNameFormat¶
- class Origin¶
- PyANGKernel.GKColumn.eLastGenerated¶
- __init__()¶
Returns true if enums strings have been associated in this column.
- static buildAutomaticName(contents, type)¶
- Parameters:
contents –
GKContentstype –
GKType
- Return type:
Builds an automatic name based on the specified contents and type.
Returns the automatic name of the column based on its contents and type.
See
TypeReturns a user readable name of the column data type
Returns the specified content of the column
Returns content GK::eContentMain (cached) of the column
- getContents()¶
- Return type:
Returns all the contents of the column.
- getConversion()¶
- Return type:
See
GKColumndescription. To know if two columns have the same type usegetConversionNameinstead as the comversion can be set to None and the user can set a name (veh/h for example for Flow).Returns the name of the units when the conversion is set to None. As set by
setConversion- getConversionName(units)
- Parameters:
units –
UnitSystem- Return type:
Returns the name of the units in metric or imperial units.
Returns the name of the units when the conversion is set to None, translated to the user language (if available). As set by
setConversion- getConversionNameTranslated(units)
- Parameters:
units –
UnitSystem- Return type:
Returns the name of the units in metric or imperial units, translated to the user language (if available)
A free text describing this columns.
Returns the position of a string in an Enum. If the string is not found it will return a -1
Returns the string associated with this value (if any) or the value itself as an string. Note that the value is a float to be used by enums and by time series.
- getEnumStrings()¶
- Return type:
Dictionary with keys of type .qint32 and values of type QString.
Returns all the enums strings, both the value and the associated string
The external name of the group of this column
- getExternalName([format=GKColumn.GKColumnNameFormat.eLongFormat])¶
- Parameters:
format –
GKColumnNameFormat- Return type:
The name of this column as shown to the user. Can be edited and translated. If the column is a timeSeries it can offer the name in either a long format, medium format and short format: - Long format: the external name as set by the user - Medium format: using the name of all the contents - Short format: using the name of the eContainMain content.
Returns the
Typestored on the fileThe group of this column
The ID of this column, valid during the life of system. This information is not store and will change every time a new system is created.
The internal, unique name of this column.
Gets the text for the null object. By default it is None
Gets if the object can be a null object or not * By default objects cannot be null.
Returns the type of the objects that attributes of this column type can hold if the column type is
_GKObject, or NULL for any type.Returns a user readable name of the origin
The object that has created this column (replication data after a simulation for example). Can be NULL as it is optional.
- static getOriginator(originatorId, model)
Returns the object that corresponds to the specified id ; - ‘0’ stands for NULL. - eLastGenerated stands for the last generated simulation.
Returns the id of the object that has created this column. - ‘0’ stands for NULL. - eLastGenerated stands for the last generated simulation.
Returns the number of decimals of precision for this column.
Gets the python code for this attribute.
- getPythonFunction()¶
- Return type:
void
Returns the compiled function. It returns a PyObject pointer but the declaration cannot be on this header as Python define the symbols that cannot be use in Qt (signal). If secondaryFunction is a valid void**, the secondary python function is written in it.
Returns (if any) the real column. See
setRealColumn- getStoreType()¶
- Return type:
See
GKColumnType- static getStoreTypeName(atype)¶
- Parameters:
atype –
GKColumnType- Return type:
Returns a user readable name of the column storage type
- getTSDescription()¶
- Return type:
If the column type is
_GKTimeSerie, the descriptionThe type in where this column is.
True if this column can be use in a view style
Returns the value of a column in metric system from the selected units. Units comes from the current model (
getUnitSystem)- getValueFromGui(units, value)
- Parameters:
units –
UnitSystemvalue – float
- Return type:
Returns the value of a column in metric system from the selected units.
Returns the value of a column in the selected units. Units comes from the current model (
getUnitSystem)- getValueToGui(units, value)
- Parameters:
units –
UnitSystemvalue – float
- Return type:
Returns the value of a column in the selected units.
Returns true if this column holds numeric values (Time Series and Segmented Attr. are numeric values too). Note that
_GKObjectare stored using the object id so they are numbers but this method will return false for_GKObjectas they are “soft pointers” to objects rather that numeric values that can be manipulated using arithmetic operations.If by area the values of this attribute are related to the area of the object.
- isConversionCompatible(column, units)¶
- Parameters:
column –
GKColumnunits –
UnitSystem
- Return type:
Returns true if the values for this column can be translated in values for the column given as parameter. Two columns will be compatible when they have the same conversion or when their conversion can be translated into the other column units (for example, veh and vehs/h are compatible as they can be compared if translated one to the other .
Returns true if the column has no value in all objects and there is at least one object of the type.
Returns true if the column has a 0 value in all objects and there is at least one object of the type.
Returns true if the column is a dynamic column. See GKColumn::dynamic
If true the column values (in each object) can be edited by the user, if false only the application can set the values or is executable code (ie Python).
True if this column can be used to calculate GEH
See also
If true, the column values (for each object) can be overriden in experiments through the network attribute overrides mechanism. By default, only those standard variables the simulator is using are overridable.
See also
Returns true if the column is real.
Note
This is different from
getRealColumn():getRealColumn()may be NULL and isReal() true. But if isReal() is false,getRealColumn()will always be NULL. The reason for this is that the real column ID can’t be stored/restored, as it’s application-temporary.- static parseAutomaticName(automaticName, outContents, outTypeName)¶
- Parameters:
automaticName – str
outContents –
GKContentsoutTypeName – str
Parses the specified automatic column name, and writes its corresponding
GKContentsandGKTypename in the corresponding output arguments.- setByArea(value)¶
- Parameters:
value – bool
If by area the values of this attribute are related to the area of the object.
See also
See
Type- setContents(values)¶
- Parameters:
values –
GKContents
Sets the
GKContents.- setConversion(type[, noneName=""[, noneNameTranslated=""]])¶
- Parameters:
type –
ConversionnoneName – str
noneNameTranslated – str
See
GKColumndescription. If the conversion is none the user still can set the units name using the noneName parameter. This is the string (unmodified) that will returngetConversionNamewhen the conversion is set to None.- setDescription(adescription)¶
- Parameters:
adescription – str
A free text describing this columns.
- setDynamic(value)¶
- Parameters:
value – bool
Sets this column as dynamic (true) or static (false). See GKColumn::dynamic
See also
- setEditable(value)¶
- Parameters:
value – bool
If true the column values (in each object) can be edited by the user, if false only the application can set the values.
See also
- setEnumString(value, string)¶
- Parameters:
value – int
string – str
Set the name of a particular value.
- setExternalGroupName(name)¶
- Parameters:
name – list of strings
The external name of the group of this column
- setExternalName(aname)¶
- Parameters:
aname – str
The name of this column as shown to the user. Can be edited and translated.
- setGroupName(name)¶
- Parameters:
name – list of strings
The group of this column
- setId(aid)¶
- Parameters:
aid – int
The ID of this column, valid during the life of system. This information is not store and will change every time a new system is created.
- setIsGEHColumn(value)¶
- Parameters:
value – bool
True if this column can be used to calculate GEH
See also
- setName(iname)¶
- Parameters:
iname – str
The internal, unique name of this column.
- setNullObjectText(text)¶
- Parameters:
text – str
If the column type is
_GKObjectand it can be null sets the text for the null object. * By default it is None- setObjectCanBeNull(canBeNull)¶
- Parameters:
canBeNull – bool
If the column type is
_GKObjectsets if the object can be a null object or not. * By default objects cannot be null.- setObjectType(typeName)¶
- Parameters:
typeName – str
If the column type is
_GKObjectsets the type of the objects that can hold (or NULL for any type).- setOverridable(value)¶
- Parameters:
value – bool
If true the column values (for each object) can be overriden in experiments through the network attribute overrides mechanism. Caution: If you set a column to overridable, in general you should access its value through getModelConnection() in order to set the context that defines if an override is active or not. This is not needed for Aimsun cost functions, as they receive simulated objects (for example, simulated section instead of
GKSection) which already evaluate correctly (as would the section.getModelConnection()).- setPrecision(precision)¶
- Parameters:
precision – int
Sets the number of decimals of precision for this column.
- setPythonCode(code)¶
- Parameters:
code – str
Sets the python code for this attribute. Changes the attribute type to
ePython.Set a column as real for this one. That means that, when reading or setting data using this column data will be read or set in the real column.
This column, thus, can be considered an alias of the real column.
- setStoreType(atype)¶
- Parameters:
atype –
GKColumnType
See
GKColumnType- setTSDescription(ts)¶
- Parameters:
ts –
GKTSDescription
If the column type is
_GKTimeSerie, the descriptionThe type in where this column is.
- setUsableInStyle(value)¶
- Parameters:
value – bool
True if this column can be use in a view style