| /** |
| * ******************************************************************************* |
| * Copyright (c) 2019 Robert Bosch GmbH and others. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Robert Bosch GmbH - initial API and implementation |
| * ******************************************************************************* |
| */ |
| |
| package templates.m2m.utils; |
| |
| import org.eclipse.app4mc.amalthea.model.Time |
| import templates.AbstractAmaltheaInchronTransformer |
| import com.google.inject.Singleton |
| |
| @Singleton |
| class TimeTransformer extends AbstractAmaltheaInchronTransformer { |
| |
| def create inchronModelFactory.createTime createTime(Time amltTime) { |
| |
| val amltValue = amltTime?.value |
| it.value = if(amltValue !== null) amltValue.longValue else 0; |
| |
| switch (amltTime?.unit) { |
| case S: |
| it.unit = com.inchron.realtime.root.model.TimeUnit.S |
| case MS: |
| it.unit = com.inchron.realtime.root.model.TimeUnit.MS |
| case US: |
| it.unit = com.inchron.realtime.root.model.TimeUnit.US |
| case NS: |
| it.unit = com.inchron.realtime.root.model.TimeUnit.NS |
| case PS: |
| it.unit = com.inchron.realtime.root.model.TimeUnit.PS |
| case _UNDEFINED_: |
| it.unit = com.inchron.realtime.root.model.TimeUnit.PS |
| } |
| } |
| |
| } |