Zakir Meer | c3b605a | 2019-02-12 12:28:40 +0100 | [diff] [blame] | 1 | package templates.m2m.hw |
| 2 | |
| 3 | import com.inchron.realtime.root.model.TimeUnit |
| 4 | import javax.inject.Inject |
| 5 | import org.eclipse.app4mc.amalthea.model.FrequencyDomain |
| 6 | import templates.AbstractAmaltheaInchronTransformer |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame^] | 7 | import templates.m2m.utils.FrequencyTransformer |
Zakir Meer | c3b605a | 2019-02-12 12:28:40 +0100 | [diff] [blame] | 8 | import templates.utils.AmltCacheModel |
| 9 | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 10 | class FrequencyDomainTransformer extends AbstractAmaltheaInchronTransformer { |
| 11 | |
Zakir Meer | c3b605a | 2019-02-12 12:28:40 +0100 | [diff] [blame] | 12 | @Inject FrequencyTransformer frequencyTransformer |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 13 | |
| 14 | def create inchronModelFactory.createClock createClock(FrequencyDomain amltFrequencyDomain) { |
| 15 | |
| 16 | it.name = amltFrequencyDomain.name |
| 17 | |
| 18 | var amltFrequency = amltFrequencyDomain.defaultValue |
| 19 | |
| 20 | if (amltFrequency !== null) { |
| 21 | it.frequency = frequencyTransformer.createFrequency(amltFrequency) |
| 22 | |
Zakir Meer | c3b605a | 2019-02-12 12:28:40 +0100 | [diff] [blame] | 23 | // var amltFrequeny_Hz=AmaltheaServices.convertToHertz(amltFrequency) |
Zakir Meer | c3b605a | 2019-02-12 12:28:40 +0100 | [diff] [blame] | 24 | // var amltTime=amaltheaFactory.createTime |
Zakir Meer | c3b605a | 2019-02-12 12:28:40 +0100 | [diff] [blame] | 25 | // var BigDecimal result=BigDecimal.TEN.pow(12).divide(amltFrequeny_Hz) |
| 26 | // |
| 27 | // amltTime.value = result.toBigInteger |
| 28 | // amltTime.unit=TimeUnit.PS |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | // TODO: This is only temporary. In future this will be a default value in Inchron model |
| 32 | var range = inchronModelFactory.createTime |
| 33 | range.unit = TimeUnit.S |
| 34 | range.value = 1 |
| 35 | it.range = range |
| 36 | |
| 37 | it.startTimeFixed = inchronModelFactory.createTime |
| 38 | it.startTimeMin = inchronModelFactory.createTime |
| 39 | it.startTimeMax = inchronModelFactory.createTime |
| 40 | it.startValue = inchronModelFactory.createTime |
| 41 | |
| 42 | // Caching model element |
| 43 | val AmltCacheModel cacheModel = customObjsStore.getInstance(AmltCacheModel) |
| 44 | cacheModel.addInchronClock(it) |
| 45 | } |
| 46 | |
| 47 | } |