PyANGKernel.GKColumn

class GKColumn

Attribute for a type.

Details

The GKColumn hold 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

  • _GKTimeSerie : A GKTimeSerie

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 getName and setName and one external accessible with getExternalName and setExternalName . 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 GKType for 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 using setExternalGroupName .

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 GKColumn can be marked as one of the following types via setConversion and getConversion : - 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.

See also

GKType GKObject

Synopsis

Methods

Static functions

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 GKObject pointer, GKTimeSerie , GKEnum and GKTimeDuration They 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__()
anyEnumString()
Return type:

bool

Returns true if enums strings have been associated in this column.

static buildAutomaticName(contents, type)
Parameters:
Return type:

str

Builds an automatic name based on the specified contents and type.

getAutomaticName()
Return type:

str

Returns the automatic name of the column based on its contents and type.

getColumnType()
Return type:

Type

See Type

static getColumnTypeName(atype)
Parameters:

atypeType

Return type:

str

Returns a user readable name of the column data type

getContent(type)
Parameters:

type – str

Return type:

GKContent

Returns the specified content of the column

getContentMain()
Return type:

GKContent

Returns content GK::eContentMain (cached) of the column

getContents()
Return type:

GKContents

Returns all the contents of the column.

getConversion()
Return type:

Conversion

See GKColumn description. To know if two columns have the same type use getConversionName instead as the comversion can be set to None and the user can set a name (veh/h for example for Flow).

getConversionName()
Return type:

str

Returns the name of the units when the conversion is set to None. As set by setConversion

getConversionName(units)
Parameters:

unitsUnitSystem

Return type:

str

Returns the name of the units in metric or imperial units.

getConversionNameTranslated()
Return type:

str

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:

unitsUnitSystem

Return type:

str

Returns the name of the units in metric or imperial units, translated to the user language (if available)

getDescription()
Return type:

str

A free text describing this columns.

getEnumPosition(value)
Parameters:

value – str

Return type:

int

Returns the position of a string in an Enum. If the string is not found it will return a -1

getEnumString(value)
Parameters:

value – float

Return type:

str

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

getExternalGroupName()
Return type:

list of strings

The external name of the group of this column

getExternalName([format=GKColumn.GKColumnNameFormat.eLongFormat])
Parameters:

formatGKColumnNameFormat

Return type:

str

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.

getFileColumnType()
Return type:

Type

Returns the Type stored on the file

getGroupName()
Return type:

list of strings

The group of this column

getId()
Return type:

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.

getName()
Return type:

str

The internal, unique name of this column.

getNullObjectText()
Return type:

str

Gets the text for the null object. By default it is None

getObjectCanBeNull()
Return type:

bool

Gets if the object can be a null object or not * By default objects cannot be null.

getObjectType()
Return type:

GKType

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.

getOrigin()
Return type:

Origin

getOriginDescription()
Return type:

str

static getOriginName(origin)
Parameters:

originOrigin

Return type:

str

Returns a user readable name of the origin

getOriginator()
Return type:

GKObject

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)
Parameters:
  • originatorId – int

  • modelGKModel

Return type:

GKObject

Returns the object that corresponds to the specified id ; - ‘0’ stands for NULL. - eLastGenerated stands for the last generated simulation.

getOriginatorId()
Return type:

int

Returns the id of the object that has created this column. - ‘0’ stands for NULL. - eLastGenerated stands for the last generated simulation.

getPrecision()
Return type:

int

Returns the number of decimals of precision for this column.

getPythonCode()
Return type:

str

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.

getRealColumn()
Return type:

GKColumn

Returns (if any) the real column. See setRealColumn

getStoreType()
Return type:

GKColumnType

See GKColumnType

static getStoreTypeName(atype)
Parameters:

atypeGKColumnType

Return type:

str

Returns a user readable name of the column storage type

getTSDescription()
Return type:

GKTSDescription

If the column type is _GKTimeSerie , the description

getType()
Return type:

GKType

The type in where this column is.

getUsableInStyle()
Return type:

bool

True if this column can be use in a view style

getValueFromGui(value)
Parameters:

value – float

Return type:

float

Returns the value of a column in metric system from the selected units. Units comes from the current model ( getUnitSystem )

getValueFromGui(units, value)
Parameters:
Return type:

float

Returns the value of a column in metric system from the selected units.

getValueToGui(value)
Parameters:

value – float

Return type:

float

Returns the value of a column in the selected units. Units comes from the current model ( getUnitSystem )

getValueToGui(units, value)
Parameters:
Return type:

float

Returns the value of a column in the selected units.

hasNumericValues()
Return type:

bool

Returns true if this column holds numeric values (Time Series and Segmented Attr. are numeric values too). Note that _GKObject are stored using the object id so they are numbers but this method will return false for _GKObject as they are “soft pointers” to objects rather that numeric values that can be manipulated using arithmetic operations.

isByArea()
Return type:

bool

If by area the values of this attribute are related to the area of the object.

isConversionCompatible(column, units)
Parameters:
Return type:

bool

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 .

isDataValueNullInAllObjects()
Return type:

bool

Returns true if the column has no value in all objects and there is at least one object of the type.

isDataValueZeroInAllObjects()
Return type:

bool

Returns true if the column has a 0 value in all objects and there is at least one object of the type.

isDynamic()
Return type:

bool

Returns true if the column is a dynamic column. See GKColumn::dynamic

isEditable()
Return type:

bool

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).

isGEHColumn()
Return type:

bool

True if this column can be used to calculate GEH

See also

setIsGEHColumn()

isOverridable()
Return type:

bool

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.

isReal()
Return type:

bool

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

  • outContentsGKContents

  • outTypeName – str

Parses the specified automatic column name, and writes its corresponding GKContents and GKType name 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

isByArea()

setColumnType(atype)
Parameters:

atypeType

See Type

setContents(values)
Parameters:

valuesGKContents

Sets the GKContents .

setConversion(type[, noneName=""[, noneNameTranslated=""]])
Parameters:
  • typeConversion

  • noneName – str

  • noneNameTranslated – str

See GKColumn description. If the conversion is none the user still can set the units name using the noneName parameter. This is the string (unmodified) that will return getConversionName when 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

isDynamic()

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

isEditable()

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

isGEHColumn()

setName(iname)
Parameters:

iname – str

The internal, unique name of this column.

setNullObjectText(text)
Parameters:

text – str

If the column type is _GKObject and 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 _GKObject sets 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 _GKObject sets the type of the objects that can hold (or NULL for any type).

setOrigin(from[, originDesc=std.string()])
Parameters:
  • fromOrigin

  • originDesc – str

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 .

setRealColumn(acol)
Parameters:

acolGKColumn

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:

atypeGKColumnType

See GKColumnType

setTSDescription(ts)
Parameters:

tsGKTSDescription

If the column type is _GKTimeSerie , the description

setType(atype)
Parameters:

atypeGKType

The type in where this column is.

setUsableInStyle(value)
Parameters:

value – bool

True if this column can be use in a view style