blob: 79c210c9a15fa58cf35e3e32fc349150fa66f3b2 [file] [log] [blame]
Zakir Meerc3b605a2019-02-12 12:28:40 +01001package templates.m2m.hw
2
3import com.inchron.realtime.root.model.TimeUnit
4import javax.inject.Inject
5import org.eclipse.app4mc.amalthea.model.FrequencyDomain
6import templates.AbstractAmaltheaInchronTransformer
Harald Mackamulf5d17b62019-02-14 14:57:58 +01007import templates.m2m.utils.FrequencyTransformer
Zakir Meerc3b605a2019-02-12 12:28:40 +01008import templates.utils.AmltCacheModel
9
Harald Mackamul505789c2019-02-14 14:28:17 +010010class FrequencyDomainTransformer extends AbstractAmaltheaInchronTransformer {
11
Zakir Meerc3b605a2019-02-12 12:28:40 +010012 @Inject FrequencyTransformer frequencyTransformer
Harald Mackamul505789c2019-02-14 14:28:17 +010013
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 Meerc3b605a2019-02-12 12:28:40 +010023// var amltFrequeny_Hz=AmaltheaServices.convertToHertz(amltFrequency)
Zakir Meerc3b605a2019-02-12 12:28:40 +010024// var amltTime=amaltheaFactory.createTime
Zakir Meerc3b605a2019-02-12 12:28:40 +010025// var BigDecimal result=BigDecimal.TEN.pow(12).divide(amltFrequeny_Hz)
26//
27// amltTime.value = result.toBigInteger
28// amltTime.unit=TimeUnit.PS
Harald Mackamul505789c2019-02-14 14:28:17 +010029 }
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}