blob: 47b660a6da8b28db04d5171e1389402b20debae6 [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2018 Robert Bosch GmbH.
*
* 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.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.app4mc.amalthea.model.HwStructure;
import org.eclipse.app4mc.amalthea.model.InterruptController;
import org.eclipse.app4mc.amalthea.model.MappingModel;
import org.eclipse.app4mc.amalthea.model.OperatingSystem;
import org.eclipse.app4mc.amalthea.model.Process;
import org.eclipse.app4mc.amalthea.model.Scheduler;
import org.eclipse.app4mc.amalthea.model.SchedulerAllocation;
import org.eclipse.app4mc.amalthea.model.Task;
import org.eclipse.app4mc.amalthea.model.TaskAllocation;
import org.eclipse.app4mc.amalthea.model.TaskScheduler;
import org.eclipse.emf.common.util.EList;
import com.inchron.realtime.root.model.ActivationConnection;
import com.inchron.realtime.root.model.Clock;
import com.inchron.realtime.root.model.Component;
import com.inchron.realtime.root.model.CpuCore;
import com.inchron.realtime.root.model.GenericSystem;
import com.inchron.realtime.root.model.Model;
import com.inchron.realtime.root.model.RtosConfig;
import com.inchron.realtime.root.model.Semaphore;
import com.inchron.realtime.root.model.memory.Memory;
public class AmltCacheModel {
private Map<String, Clock> inchronClocksMap = new HashMap<>();
private Map<String, Memory> inchronMemoriesMap = new HashMap<>();
private Map<String, CpuCore> inchronCpuCoresMap = new HashMap<>();
private Map<String, RtosConfig> inchronRtosConfigMap = new HashMap<>();
private Map<String, Component> inchronComponentsMap = new HashMap<>();
private Map<Process, Component> amltProcess_InchronComponentMap = new HashMap<>();
private Model inchronModel;
private Map<String, ActivationConnection> amltStimuli_inchronActivationConnectionMap = new HashMap<>();
private Map<com.inchron.realtime.root.model.Process, Component> inchronProcessComponentsMap = new HashMap<>();
private Map<com.inchron.realtime.root.model.Scheduler, Scheduler> inchronScheduler_amltSchedulerMap = new HashMap<>();
private Map<HwStructure, GenericSystem> mappingAmltMicroController_GenericSystem = new HashMap<>();
private Map<Scheduler, SchedulerAllocation> scheduler_schedulerAllocationMap = new HashMap<Scheduler, SchedulerAllocation>();
private Map<Task, List<TaskAllocation>> tasks_TaskAllocationMap = new HashMap<Task, List<TaskAllocation>>();
// private Map<ISR, SchedulerAllocation> isr_schedulerAllocationMap=new HashMap<ISR, SchedulerAllocation>();
private Map<TaskScheduler, List<TaskAllocation>> taskScheduler_taskAllocationMap = new HashMap<TaskScheduler, List<TaskAllocation>>();
private Map<String, Semaphore> inchronSemaphoresMap = new HashMap<>();
private Map<String, List<org.eclipse.app4mc.amalthea.model.Process>> amltInterProcessStimuli_processActivationsMap = new HashMap<>();
private Map<String, ActivationConnection> inchronConnectionElementsMap = new HashMap<>();
private Map<String, List<com.inchron.realtime.root.model.Process>> amltStimuliInchronProcessMap = new HashMap<>();
public Map<HwStructure, GenericSystem> getMappingAmltMicroController_GenericSystem() {
return mappingAmltMicroController_GenericSystem;
}
public void cacheMappingAmltMicroController_GenericSystem(HwStructure hwStructure, GenericSystem genericSystem) {
mappingAmltMicroController_GenericSystem.put(hwStructure, genericSystem);
}
public void cacheAmltStimuliInchronProcessMap(String amltStimuliName,
com.inchron.realtime.root.model.Process inchronProcess) {
if (amltStimuliName != null) {
List<com.inchron.realtime.root.model.Process> processList = amltStimuliInchronProcessMap
.get(amltStimuliName);
if (processList == null) {
processList = new ArrayList<>();
amltStimuliInchronProcessMap.put(amltStimuliName, processList);
}
processList.add(inchronProcess);
}
}
public Map<String, List<com.inchron.realtime.root.model.Process>> getAmltStimuliInchronProcessElementsMap() {
return amltStimuliInchronProcessMap;
}
public void cacheInchronConnection(String name, ActivationConnection connection) {
if (name != null) {
inchronConnectionElementsMap.put(name, connection);
}
}
public Map<String, ActivationConnection> getInchronConnectionElementsMap() {
return inchronConnectionElementsMap;
}
public void cacheInterProcessTriggerRelations(String stimuliName, Process amltProcess) {
if (stimuliName != null) {
List<Process> processList = amltInterProcessStimuli_processActivationsMap.get(stimuliName);
if (processList == null) {
processList = new ArrayList<>();
amltInterProcessStimuli_processActivationsMap.put(stimuliName, processList);
}
processList.add(amltProcess);
}
}
public Map<String, List<Process>> getInterProcessTriggerRelationsMap() {
return amltInterProcessStimuli_processActivationsMap;
}
public void cacheInchronSemaphore(com.inchron.realtime.root.model.Semaphore inchronSemaphore) {
if (inchronSemaphore.getName() != null) {
inchronSemaphoresMap.put(inchronSemaphore.getName(), inchronSemaphore);
}
}
public com.inchron.realtime.root.model.Semaphore getInchronSemaphoreCacheElement(String semaphoreName) {
return inchronSemaphoresMap.get(semaphoreName);
}
public Map<Scheduler, SchedulerAllocation> getTaskScheduler_schedulerAllocationMap() {
return scheduler_schedulerAllocationMap;
}
public Map<Task, List<TaskAllocation>> getTasks_TaskAllocationMap() {
return tasks_TaskAllocationMap;
}
public Map<TaskScheduler, List<TaskAllocation>> getTaskScheduler_taskAllocationMap() {
return taskScheduler_taskAllocationMap;
}
public void buildProcesses_SchedulerAllocationMap(MappingModel mappingModel) {
EList<SchedulerAllocation> schedulerAllocations = mappingModel.getSchedulerAllocation();
for (SchedulerAllocation schedulerAllocation : schedulerAllocations) {
scheduler_schedulerAllocationMap.put(schedulerAllocation.getScheduler(), schedulerAllocation);
}
}
public void buildSchedulerAndSchedulerAssociationMap(MappingModel mappingModel) {
EList<SchedulerAllocation> schedulerAllocations = mappingModel.getSchedulerAllocation();
for (SchedulerAllocation schedulerAllocation : schedulerAllocations) {
Scheduler scheduler = schedulerAllocation.getScheduler();
if (scheduler instanceof TaskScheduler) {
scheduler_schedulerAllocationMap.put(scheduler, schedulerAllocation);
} else if (scheduler instanceof InterruptController) {
// isr_schedulerAllocationMap.put(((InterruptController)scheduler).getISR, schedulerAllocation);
}
}
}
public Map<Scheduler, SchedulerAllocation> getScheduler_SchedulerAllocationMap() {
return scheduler_schedulerAllocationMap;
}
public Map<TaskScheduler, List<TaskAllocation>> getTaskScheduler_TaskAllocationMap() {
return taskScheduler_taskAllocationMap;
}
public void buildTaskSchedulerAndTaskAllocationMap(MappingModel mappingModel) {
EList<TaskAllocation> taskAllocations = mappingModel.getTaskAllocation();
for (TaskAllocation taskAllocation : taskAllocations) {
List<TaskAllocation> listOfTaskAllocations;
if (taskScheduler_taskAllocationMap.containsKey(taskAllocation.getScheduler())) {
listOfTaskAllocations = taskScheduler_taskAllocationMap.get(taskAllocation.getScheduler());
} else {
listOfTaskAllocations = new ArrayList<TaskAllocation>();
taskScheduler_taskAllocationMap.put(taskAllocation.getScheduler(), listOfTaskAllocations);
}
listOfTaskAllocations.add(taskAllocation);
// populating map tasks_TaskAllocationMap
List<TaskAllocation> listOftask_TaskAllocations;
if (tasks_TaskAllocationMap.containsKey(taskAllocation.getTask())) {
listOftask_TaskAllocations = tasks_TaskAllocationMap.get(taskAllocation.getTask());
} else {
listOftask_TaskAllocations = new ArrayList<TaskAllocation>();
tasks_TaskAllocationMap.put(taskAllocation.getTask(), listOftask_TaskAllocations);
}
listOftask_TaskAllocations.add(taskAllocation);
}
}
public Map<OperatingSystem, List<TaskScheduler>> groupTaskSchdulers(Iterable<TaskScheduler> rootTaskSchedulers) {
Map<OperatingSystem, List<TaskScheduler>> map = new HashMap<>();
for (TaskScheduler taskScheduler : rootTaskSchedulers) {
List<TaskScheduler> list = map.get(taskScheduler.eContainer());
if (list == null) {
list = new ArrayList<TaskScheduler>();
map.put((OperatingSystem) taskScheduler.eContainer(), list);
}
list.add(taskScheduler);
}
return map;
}
public void addInchronClock(Clock obj) {
inchronClocksMap.put(obj.getName(), obj);
}
public Clock getInchronClock(String name) {
return inchronClocksMap.get(name);
}
public Map<String, Clock> getInchronClocksMap() {
return inchronClocksMap;
}
public void addInchronScheduler_amltSchedulerMap(com.inchron.realtime.root.model.Scheduler inchronScheduler,
Scheduler amltScheduler) {
inchronScheduler_amltSchedulerMap.put(inchronScheduler, amltScheduler);
}
public Scheduler getAmltSchedulerFromInchronScheduler(com.inchron.realtime.root.model.Scheduler inchronScheduler) {
return inchronScheduler_amltSchedulerMap.get(inchronScheduler);
}
public Map<com.inchron.realtime.root.model.Scheduler, Scheduler> getInchronScheduler_amltSchedulerMap() {
return inchronScheduler_amltSchedulerMap;
}
public void addInchronRtosConfig(RtosConfig obj) {
inchronRtosConfigMap.put(obj.getName(), obj);
}
public RtosConfig getInchronRtosConfig(String name) {
return inchronRtosConfigMap.get(name);
}
public void addInchronMemory(Memory inchronMemory) {
inchronMemoriesMap.put(inchronMemory.getName(), inchronMemory);
}
public Memory getInchronMemory(String name) {
return inchronMemoriesMap.get(name);
}
public void addInchronCpuCore(CpuCore cpuCore) {
inchronCpuCoresMap.put(cpuCore.getName(), cpuCore);
}
public CpuCore getInchronCpuCore(String name) {
return inchronCpuCoresMap.get(name);
}
public void addInchronComponent(Component component) {
inchronComponentsMap.put(component.getName(), component);
}
public Component getInchronComponent(String name) {
return inchronComponentsMap.get(name);
}
public void addAmltProcess_InchronComponent(Process amltProcess, Component inchronComponent) {
amltProcess_InchronComponentMap.put(amltProcess, inchronComponent);
}
public Component getInchronComponent(Process amltProcess) {
return amltProcess_InchronComponentMap.get(amltProcess);
}
public Map<String, ActivationConnection> getAmltStimuli_inchronActivationConnectionMap() {
return amltStimuli_inchronActivationConnectionMap;
}
public void addAmltStimuli_inchronActivationConnection(String amltStimuliName,
ActivationConnection inchronActivationConnection) {
amltStimuli_inchronActivationConnectionMap.put(amltStimuliName, inchronActivationConnection);
}
public Model getInchronModel() {
return inchronModel;
}
public void setInchronModel(Model inchronModel) {
this.inchronModel = inchronModel;
}
}