Package org.destecs.protocol.exceptions

Examples of org.destecs.protocol.exceptions.RemoteSimulationException


      if (mainContext.threadState != null
          && mainContext.threadState.dbgp != null
          && mainContext.threadState.dbgp instanceof DBGPReaderCoSim
          && ((DBGPReaderCoSim) mainContext.threadState.dbgp).getStatus() == DBGPStatus.STOPPED)
      {
        throw new RemoteSimulationException("VDM Main Thread no longer active. Forced to stop before end time.", null);
      }
    } else
    {
      throw new RemoteSimulationException("Interpreter is not correctly initialized.", null);
    }

    for (StepinputsStructParam p : inputs)
    {
      setValue(p.name, CoSimType.Auto, new ValueContents(p.value, p.size));
    }

    nextTimeStep = outputTime.longValue();
    debug("Next Step clock: " + nextTimeStep);

    if (events.size() > 0)
    {
      for (String event : events)
      {
        evalEvent(event);
      }
    }

    try
    {
      interpreterRunning = true;
      SharedStateListner.resetAutoIncrementTime();
      notify();// Wake up Scheduler

      while (interpreterRunning)
      {
        this.wait();// Wait for scheduler to notify
      }
    } catch (Exception e)
    {
      debugErr(e);
      throw new RemoteSimulationException("Notification of scheduler faild", e);
    }
    debug("Next Step return at clock: " + nextTimeStep);

    this.status = CoSimStatusEnum.STEP_TAKEN;

    List<StepStructoutputsStruct> outputs = new Vector<StepStructoutputsStruct>();

    for (String key : links.getOutputs().keySet())
    {
      try
      {
        ValueContents value = getOutput(key);
        if (value != null)
        {
          outputs.add(new StepStructoutputsStruct(key, value.value, value.size));
        } else
        {
          throw new RemoteSimulationException("Faild to get output parameter, output not bound for: "
              + key);
        }
      } catch (ValueException e)
      {
        debugErr(e);
        throw new RemoteSimulationException("Faild to get output parameter", e);
      }
    }

    StepStruct result = new StepStruct(StepResultEnum.SUCCESS.value, new Double(nextSchedulableActionTime), new Vector<String>(), outputs);
View Full Code Here


            BasicSchedulableThread.remove(eThread);
            evaluated = true;
          } catch (ValueException e)
          {
            debugErr(e);
            throw new RemoteSimulationException("Faild to evaluate event: "
                + event, e);
          }

        }
      }
    }
    if (!evaluated)
    {
      debugErr("Event: " + event + " not found");
      throw new RemoteSimulationException("Faild to find event: " + event);
    }
  }
View Full Code Here

      Value value = VDMClassHelper.digForVariable(varName.subList(1, varName.size()), list).value;

      if (value.deref() instanceof UndefinedValue)
      {
        throw new RemoteSimulationException("Value: " + name
            + " not initialized");
      }

      return new ValueContents(VDMClassHelper.getDoubleListFromValue(value), VDMClassHelper.getValueDimensions(value));

    }
    throw new RemoteSimulationException("Value: " + name + " not found");
  }
View Full Code Here

      noOptimization = disableOptimization;
      this.variablesToLog.clear();
      // this.variablesToLog.addAll(variablesToLog);
      if (!linkFile.exists() || linkFile.isDirectory())
      {
        throw new RemoteSimulationException("The VDM link file does not exist: "
            + linkFile);
      }
      VdmLinkParserWrapper linksParser = new VdmLinkParserWrapper();
      links = linksParser.parse(linkFile);// Links.load(linkFile);

      if (links == null || linksParser.hasErrors())
      {
        throw new RemoteSimulationException("Faild to parse vdm links");
      }

      if (disableRtLog)
      {
        RTLogger.enable(false);
        controller.setLogFile(null);
      } else
      {
        File logFile = new File(outputDir, "ExecutionTrace.logrt");
        controller.setLogFile(logFile);
        RTLogger.enable(true);
        RTLogger.setLogfile(new PrintWriter(logFile));
      }

      if (Settings.timingInvChecks)
      {
        PrintWriter p = new PrintWriter(new FileOutputStream(new File(outputDir, "Timing.logtv"), false));
        RuntimeValidator.setLogFile(p);
      }
      if (!disableCoverage)
      {
        coverageDirectory = new File(outputDir, "coverage");
      }
      if (this.variablesToLog.isEmpty())
      {
        SimulationLogger.enable(false);
      } else
      {
        this.simulationLogFile = new File(outputDir, "desimulation.log");
      }
      controller.setScript(script);
      Settings.baseDir = baseDirFile;

      VDMCO.outputDir = outputDir;
      ExitStatus status = controller.parse(specfiles);

      if (status == ExitStatus.EXIT_OK)
      {
        status = controller.typeCheck();

        if (status == ExitStatus.EXIT_OK)
        {
          this.status = CoSimStatusEnum.LOADED;

        } else
        {
          final Writer result = new StringWriter();
          final PrintWriter printWriter = new PrintWriter(result);
          TypeChecker.printWarnings(printWriter);
          TypeChecker.printErrors(printWriter);
          throw new RemoteSimulationException("Type check error: "
              + result.toString());
        }
      } else
      {
        throw new RemoteSimulationException("Cannot not parse specification", null);
      }

      boolean hasScriptCall = false;
      int cpus = 0;
      this.interpreter = controller.getInterpreter();
      for (ClassDefinition def : interpreter.getClasses())
      {
        if (def instanceof SystemDefinition)
        {
          for (Definition d : def.definitions)
          {
            Type t = d.getType();

            if (t instanceof ClassType)
            {
              ClassType ct = (ClassType) t;
              if (ct.classdef instanceof CPUClassDefinition)
              {
                cpus++;
              }
            }
          }
        } else if (def instanceof ClassDefinition)
        {
          if (def.getName().equals(scriptClass))
          {
            for (Definition d : def.definitions)
            {
              if (d.getName() != null
                  && d.getName().equals(scriptOperation)
                  && (d instanceof ExplicitOperationDefinition || d instanceof ExplicitFunctionDefinition))
              {
                hasScriptCall = true;
              }
            }
          }
        }
      }

      if (!hasScriptCall)
      {
        throw new RemoteSimulationException("The specification do not contain the entrypoint: "
            + script, null);
      }

      if (cpus == 0)
      {
        throw new RemoteSimulationException("Cannot load system to few CPUS", null);
      }
      return true;

    } catch (RemoteSimulationException e)
    {
      throw e;
    } catch (Exception e)

    {
      debugErr(e);
      throw new RemoteSimulationException("Internal Error while loading the model.", e);

    }

  }
View Full Code Here

      }
      return true;
    } else
    {
      this.status = CoSimStatusEnum.NOT_INITIALIZED;
      throw new RemoteSimulationException("Status = " + this.status
          + ". Internal error: " + controller.exception != null ? controller.exception.getMessage()
          : "unknown");
    }
  }
View Full Code Here

      debugErr(e);
      if (e instanceof RemoteSimulationException)
      {
        throw (RemoteSimulationException) e;
      }
      throw new RemoteSimulationException("Faild to initialize, could not get sourcefiles", e);
    }
    return files;
  }
View Full Code Here

      {
        String[] names = name.split("\\.");
        Value v = getRawValue(Arrays.asList(names), null);
        if (v == null)
        {
          throw new RemoteSimulationException("Could not find variable: "
              + name + " logging is skipped.");
        }

        if (v instanceof UpdatableValue)
        {
View Full Code Here

        if (!links.getSharedDesignParameters().keySet().contains(parameterName))
        {
          debugErr("Tried to set unlinked shared design parameter: "
              + parameterName);
          throw new RemoteSimulationException("Tried to set unlinked shared design parameter: "
              + parameterName);
        }
        @SuppressWarnings("deprecation")
        StringPair vName = links.getBoundVariable(parameterName);
        Object[] objValue = (Object[]) parameter.get("value");
        Object[] dimension = (Object[]) parameter.get("size");

        for (ClassDefinition cd : controller.getInterpreter().getClasses())
        {
          if (!cd.getName().equals(vName.instanceName))
          {
            // wrong class
            continue;
          }
          for (Definition def : cd.definitions)
          {
            if (def instanceof ValueDefinition)
            {
              ValueDefinition vDef = (ValueDefinition) def;
              if (vDef.pattern.toString().equals(vName.variableName)
                  && vDef.isValueDefinition())
              {
                if (dimension.length == 1
                    && ((Integer) dimension[0] == 1))
                {
                  Double newValue = (Double) objValue[0];
                  found = setValueForSDP(newValue, vDef);
                } else
                {
                  // dealing with a sequence
                  if (vDef.exp instanceof SeqEnumExpression)
                  {
                    SeqEnumExpression seqEnum = (SeqEnumExpression) vDef.exp;
                    found = createSeqEnum(vName.variableName, seqEnum, objValue, dimension);
                  }

                }
              }
            }

          }
        }
        if (!found)
        {
          debugErr("Tried to set unlinked shared design parameter: "
              + parameterName);
          throw new RemoteSimulationException("Tried to set unlinked shared design parameter: "
              + parameterName);
        }
      }
    } catch (RemoteSimulationException e)
    {
      throw e;
    } catch (Exception e)
    {
      debugErr(e);
      if (e instanceof RemoteSimulationException)
      {
        throw (RemoteSimulationException) e;
      }
      throw new RemoteSimulationException("Internal error in set design parameters", e);
    }

    return true;
  }
View Full Code Here

    // it's a matrix
    {
      boolean match = checkDimentionsOfSeqEnum(seqEnum, dimensions);
      if (!match)
      {
        throw new RemoteSimulationException("Dimension of \""
            + variableName + "\" does not match the SDP ");
      }
      for (Expression exp : seqEnum.members)
      {
        if (exp instanceof SeqEnumExpression)
View Full Code Here

      if (!links.getSharedDesignParameters().keySet().contains(parameterName))
      {
        debugErr("Tried to set unlinked shared design parameter: "
            + parameterName);
        throw new RemoteSimulationException("Tried to set unlinked shared design parameter: "
            + parameterName);
      }
      @SuppressWarnings("deprecation")
      StringPair vName = links.getBoundVariable(parameterName);

      for (ClassDefinition cd : controller.getInterpreter().getClasses())
      {
        if (!cd.getName().equals(vName.instanceName))
        {
          // wrong class
          continue;
        }
        for (Definition def : cd.definitions)
        {
          if (def instanceof ValueDefinition)
          {
            ValueDefinition vDef = (ValueDefinition) def;
            if (vDef.pattern.toString().equals(vName.variableName)
                && vDef.isValueDefinition()
                && vDef.getType() instanceof RealType)
            {
              if (vDef.exp instanceof RealLiteralExpression)
              {
                RealLiteralExpression exp = ((RealLiteralExpression) vDef.exp);
                LexRealToken token = exp.value;
                List<Double> value = new Vector<Double>();
                value.add(token.value);
                List<Integer> size = new Vector<Integer>();
                size.add(1);
                return new GetDesignParametersStructdesignParametersStruct(parameterName, value, size);
              } else if (vDef.exp instanceof SeqExpression)
              {
                throw new RemoteSimulationException("getDesignParameter with type SeqExpression not supported: "
                    + vDef.exp);
              }

            }
          }
        }
      }
      if (!found)
      {
        debugErr("Tried to get unlinked shared design parameter: "
            + parameterName);
        throw new RemoteSimulationException("Tried to get unlinked shared design parameter: "
            + parameterName);
      }

    } catch (RemoteSimulationException e)
    {
      throw e;
    } catch (Exception e)
    {
      debugErr(e);
      if (e instanceof RemoteSimulationException)
      {
        throw (RemoteSimulationException) e;
      }
      throw new RemoteSimulationException("Internal error in get design parameter", e);
    }

    throw new RemoteSimulationException("Internal error in get design parameter");
  }
View Full Code Here

TOP

Related Classes of org.destecs.protocol.exceptions.RemoteSimulationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.