Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » var dependent on other var
var dependent on other var [message #1814507] Thu, 12 September 2019 12:38 Go to next message
Markus Häge is currently offline Markus HägeFriend
Messages: 56
Registered: August 2018
Member
Hello,

First the example grammar:

Model:
	Command+=COMMAND*;
	
COMMAND:
	SET;
	
SET:
	name = 'Set'
	param0 = DAC
	param1 = ADDRESS;

DAC:
	name = 'DAC' 
	value = ('0x01' | '0x02' | '0x03');

ADDRESS:
	name = 'Address'
	value = ('0x8000' | '0x3000' | '0x2000');


What I want is, that when I edit DAC.value = 0x01 the address shall be 0x8000. Same for 0x02 and 0x03 => different addresses.
I tried a while with scoping but don't find the breakthrough how to implement this.
Is there a way? The Grammar shall be fixed to this values.

thanks,
MH
Re: var dependent on other var [message #1814508 is a reply to message #1814507] Thu, 12 September 2019 12:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
maybe you can have a look at the feature called "auto edit"

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: var dependent on other var [message #1814516 is a reply to message #1814508] Thu, 12 September 2019 13:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Are you sure you really want the Address to be entered at all? It just seems to require your user to work harder and to have an opportunity to enter redundant values wrongly.

If you need it in the model, then enrich your Ecore model with a derived property that returns the address.

If you just want to read it, generate a report output with all the derived details.

If 0x01 => 0x800 is just an initial default, you can override the setDAC method to setADDRESS too.

Regards

Ed Willink
Re: var dependent on other var [message #1814554 is a reply to message #1814516] Fri, 13 September 2019 07:24 Go to previous message
Markus Häge is currently offline Markus HägeFriend
Messages: 56
Registered: August 2018
Member
Hi,
auto edit is a nice way but seems to work just in Eclipse.

For editing, i need all parameters, DAC and ADDRESS and actually some more, and I want to prevent wrong addresses. Address has to be in a certain space which is reserved. So a given value is a good starting point.

I have a look at the Ecore model and derived property.

Thanks
MH
Previous Topic:Xtend validation a unique MAC address value in language
Next Topic:Xtext & Eclipse platform
Goto Forum:
  


Current Time: Thu Apr 25 22:57:16 GMT 2024

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

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

Back to the top