Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Vorto » Vorto(Use Enum for Property)
Vorto [message #1739381] Sun, 31 July 2016 10:34 Go to next message
Guy Benhaim is currently offline Guy BenhaimFriend
Messages: 10
Registered: July 2016
Junior Member
Hi,
Can Enum be used as Property type (e.g. as opposed to String) or as Constraint over the property values?
Guy
Re: Vorto [message #1740351 is a reply to message #1739381] Fri, 12 August 2016 06:57 Go to previous messageGo to next message
Alexander Edelmann is currently offline Alexander EdelmannFriend
Messages: 39
Registered: January 2015
Member
Whenever you define a property, you have the choice of specifying the type as either primitive (String, int, double etc), as an entity, enum or dictionary type.
In the following example I use an enum as both a property type directly and to further describe a primitive type as a measurement unit:
...
import mytypes.Mood;1.0.0
import mytypes.Temp;1.0.0
...
status {
  mandatory lightMood as Mood // The enum Mood is used as a property directly
  mandatory motorHeat as float with { measurementUnit : Temp.Celsius } //use an enum to specify the value of the motorheat in celcius
}


Does this help you?

Alex
Re: Vorto [message #1740510 is a reply to message #1740351] Mon, 15 August 2016 09:44 Go to previous messageGo to next message
Guy Benhaim is currently offline Guy BenhaimFriend
Messages: 10
Registered: July 2016
Junior Member
Thx Alex, Indeed helpful.

Can we also add a constraint regarding the permitted value range of the temperature? Smile

Guy Smile
Re: Vorto [message #1740513 is a reply to message #1740510] Mon, 15 August 2016 10:12 Go to previous messageGo to next message
Guy Benhaim is currently offline Guy BenhaimFriend
Messages: 10
Registered: July 2016
Junior Member
Hi,

Adding the Unit in my project:

using com.mycompany.type.Unit; 1.0.0

events {
AlertThresholdTemperatureFahrenheit {
mandatory threshold_temperature as double with {
measurementUnit: Unit.F
}
}
}

I still get " Couldn't resolve reference to EnumLiteral 'null.Unit.F'. " error

Guy
Re: Vorto [message #1740587 is a reply to message #1739381] Mon, 15 August 2016 23:59 Go to previous message
Alexander Edelmann is currently offline Alexander EdelmannFriend
Messages: 39
Registered: January 2015
Member
Yes, you can use Enums for measurement unit constraints, e.g
namespace com.mycompany.fb
version 1.0.0
displayname "NewFunctionBlock"
description "Function block model for NewFunctionBlock"
category demo
using com.mycompany.type.Unit ; 1.0.0

functionblock NewFunctionBlock {
	events {
		AlertThresholdTemperatureFahrenheit {
			mandatory threshold_temperature as double with {measurementUnit: Unit.F }
		}
	}

}


Regarding your DSL error: I also get the same, if I do not add the using statement. You can add using statements to a model by drag&drop onto the target model.

Alex
Previous Topic:Events
Next Topic:Naming of FBs
Goto Forum:
  


Current Time: Thu Mar 28 23:50:01 GMT 2024

Powered by FUDForum. Page generated in 0.03937 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top