blob: b3998c576e6fd0a398660be9d1be95bb440504dd [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2021 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 org.eclipse.app4mc.amalthea.validations.sim.hardware;
import java.util.List;
import org.eclipse.app4mc.amalthea.model.HwConnection;
import org.eclipse.app4mc.amalthea.validation.core.AmaltheaValidation;
import org.eclipse.app4mc.validation.annotation.Validation;
import org.eclipse.app4mc.validation.core.ValidationDiagnostic;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
/**
* Checks the sanity of HwConnection attributes.
*
* <ul>
* <li>Read latency must be set</li>
* <li>Write latency must be set</li>
* <li>Data rate must be set</li>
* </ul>
*/
@Validation(
id = "Sim-HW-Connection",
checks = { "Either read AND write latency, or datarate, or both must be set"})
public class SimHwConnection extends AmaltheaValidation {
@Override
public EClassifier getEClassifier() {
return ePackage.getHwConnection();
}
@Override
public void validate(EObject eObject, List<ValidationDiagnostic> results) {
if (eObject instanceof HwConnection) {
HwConnection con = (HwConnection) eObject;
if (con.getReadLatency() == null && con.getDataRate() == null) {
addIssue(results, con, ePackage.getHwConnection_ReadLatency(),
objectInfo(con) + ": Neither read/write latency nor data rate specified");
}
if (con.getWriteLatency() == null && con.getDataRate() == null) {
addIssue(results, con, ePackage.getHwConnection_WriteLatency(),
objectInfo(con) + ": Neither read/write latency nor data rate specified");
}
}
}
}