How do I set the length of an attribute on a class diagram in EA? - enterprise-architect

I have a class diagram and have defined an element on this diagram, and created a custom code engineering datatypes type, which allows a fixed width field, for which I want to define a length.
I just can't see where to enter it. The attributes window shows Name, Type, Scope, Stereotype, Alias and Initial Value but doesn't seem to allow anywhere to set the length or precision values.
I want to be able to use this in the report template Att.Length.
I'm sure I've done this before in an earlier version but I can't find where to set this on EA 14.
I'm sure I'm missing something obvious, but I've looked in every properties window I can find.
Thanks for looking! :-)

Length is typically not used with code engineering datatypes, but with database datatypes.
In that case this is intended to be used in database models, and EA will present a different GUI that enables you to edit the length of the datatype.
Technically these field are stored in t_attribute.Length in case of a type such as char, or t_attribute.Precision and t_attribute.Scale in case of a type such as numeric.
There is no (easy) way to fill in these field for regular (non «column») attributes.

Related

Postico GUI: How to setup an enum data type

I'm using Postico's GUI interface to define a table, but I need an enum data type for a column. I'm not finding anything in the documentation or online that clearly denotes how I setup the enum data type for use. What I do find are various changelist statements about improved support for enums, but no details on how to actually set up that type.
I've tried putting in the Type column both of the following, hoping it would "trigger" or define it automatically...
enum
enum ('Choice1', 'Choice2')
... but both were rejected as invalid. I know that theoretically, I should be able to name and define the enum somewhere else and then use the name I defined in my data type here. But where/how do I define that in Postico?
So I have not found a way to directly define it in the GUI (which is what I was wanting to know). If someone knows how, post here and I'll accept that answer. In the mean time, execute a SQL Query in Postico's query interface
to define the type, like so:
CREATE TYPE your_type_name AS ENUM ('Choice1', 'Choice2');
After that, then the GUI interface allows you to set the type on a column.

Anylogic: Declare parameter of type ArrayList

I'm building a class (sorry - Agent) that will work with a set of Tank objects (Fluid Library) - doing things like monitoring individual levels or total level of all tanks, reporting on levels and initiating actions based on levels - things of that nature. For argument's sake let's call it a "TankMonitor" agent.
Ideally I'd like to be able to define a Parameter in my "TankMonitor" agent that allows me to define the tanks of interest when I place a TankMonitor in main. I have tried to define the type of the parameter as Other - ArrayList<Tank> however I don't know how to set up the next step to allow me to populate the ArrayList of Tanks when I put an instance of this agent in main. My preference would be to have a list type control to populate the ArrayList - much like the way the AnyLogic Seize block allows you to specify multiple resource pools to choose from.
Has anyone attempted this before and been successful?
This is possible as follows:
Change the type to "Other" and then 'Tank[]' , i.e. an Array of Tanks
Change the control type to "one-dimensional array"
Example below. Now you have the same UI to pre-define tanks at design time for your agent instance.
In addition to Benjamin's perfect answer, I'd just add the manual workaround, which is not needed here but can be useful when the parameter in question has a more complicated structure than covered by the pre-made controls, say a list of lists, a map, or similar.
In such a case, the Control Type is still Text, and populating it in an instance happens by pointing it to a new object of the parameter's type. E.g. for an ArrayList<Tank> parameter, you might instantiate a new ArrayList object, which you fill with a list of objects like so:
new ArrayList<Tank>(Arrays.asList(tankA, tankB))
In the Java code, whatever is written into that text box will end up on the right side of a parameter assignment statement in the embedded Agent instance's auto-generated parameter setup function. Therefore, multi-statement code won't work in this spot. Instead, if the process of building the parameter value doesn't fit neatly into a single expression, you can hide the code in a function which returns the desired object, and call that from the parameter's text box.

Simulink & Masks: Dynamic access to parameters "evaluate" and "tunable"

First of all, matlab version is 2011b, so I cannot use Simulink.MaskParameters class.
I have one simulink mask and some parameters inside. I need to determine in my function for each parameter if it is "evaluable" or "tunable".
Those two things are two checkboxes in the mask parameters dialog which you can select for any parameter.
For "tunable", there's the MaskTunableValues property. For "enable", there's the "MaskEnables" property.
Do you know if there's a way to programmatically access the same property but for "evaluate" ?
Thanks
#Phil Goddard's answer shows you how to find the parameter. To complete the answer, the actual parameter is MaskVariables. Evaluate flag is embedded into the MaskVariables string. It is not straightforward to modify this. For example for two parameters MaskVariables string contains something like this:
"a=#1;b=&2;"
In this string the # sign indicates evaluation. Based on that, parameter a is evaluated and parameter b is not. If you want to change the evaluate flag, you need to set this string for MaskVariables parameter exactly how it was except for # or & signs.
For more information see R2011b documentation for mask parameters at https://www.mathworks.com/help/releases/R2011b/toolbox/simulink/slref/f23-18517.html. Towards the bottom of the page there is more detail about MaskVariables parameter.
You're using too old a release for most people to be able to give you an exact solution, however, I'm sure (from memory) that this parameter is available.
If you click on the mask to select the block, then go to the MATLAB command line and type
get_param(gcb,'ObjectParameters')
you'll get a list of all the block properties. (You may already know that since you're aware of MaskTunableValues and MaskEnables.) Near the bottom of that list are all of the properties related to the mask.
Now manually look at each/all of those properties, e.g.
get_param(gcb,'MaskTunableValues')
and you'll find that one of them is a structure that contains the information that you're looking for. (You may need to dig down into the structure to find the specific info.)
Answer for versions > 2011b (tested on 2014b):
Ok found it, actually the matlab documentation is REALLY unclear regarding the Simulink.MaskParameter class and here is how it works:
First, get the Mask class from your block:
mask = Simulink.Mask.get(gcb)
The Mask class is a structure containing all mask parameters:
parameters = mask.Parameters(:)
parameters is a (array of) Simulink.MaskParameter object which will contains all the necessary properties, including Evaluate.

Setting different Cell-Formats in a Matlab uitable

I am looking for a way to handle different type of data in one column of a Matlab uitable.
Usually uitable is used to set whole columns to the same data type, such as logical (gives a checkboxes), char (gives left-aligned text), numeric (gives right-aligned number) or a 1xn-cell-array (gives pop-up menus with different choices).
It is set using the columnformat property of uitable, e.g.
columnformat = {'numeric', 'logical', {'Fixed' 'Adjustable'}}; % 3 columns
You can find an example at matlab documentation.
I am looking for a way to set the format for single cells to realize something like this:
Matlab's uitable is a crippled version of an underlying JIDE table.
It is possible to get to the underlying java (see findjobj in file exchange), but that requires a lot of work. Yair Altman's undocumented matlab site is a good starting place for understanding the java side of matlab.
It sounds like you want something like a property editor, as opposed to a generic UI table -- i.e. properties listed in first column, property value editable in second column. There are a few "off the shelf" versions in the file exchange, which use JIDE:
See propertiesgui, or property-grid for mostly functional examples. The second example is easier to use -- you simply provide a class or struct, and it creates the proper field entry format. The first one offers more choices -- like color boxes, drop downs, etc, but requires you to be more involved in specifying how things behave.
I had the same problem, but in the end it worked by giving the (numeric) cell an (char) initial value. When changing the char value from the UI the format of the cell remained char, although the rest of the column was numeric.

Set Defaults on attribute

In EA I when I am adding attributes to a class I use the insert button. I would like to change the default new attribute to be public and of type string. I quickly did a search and found nothing. EA is hard to search for based on so many bogus responses.
So I thought I would quickly ask here.
Thanks in advance.
I'm fairly sure there isn't an option for this.
If you create your own UML profile (with a customized diagram type), you can set the default attribute type for attributes created from the diagram toolbox (not from within the Properties dialog), but even then there isn't a way to specify the default visibility.