bool PluggableSimulator::OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
                                                         const openfluid::ware::WareParamKey_t& ParamName,
                                                         std::vector<long>& Vals) const
{
  bool IsOK = false;

  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
  {
    openfluid::core::VectorValue Vect;

    IsOK = it->second.toVectorValue(";",Vect);

    if(IsOK)
    {
      Vals.clear();

      for (unsigned long i=0;i<Vect.size();i++)
        Vals.push_back(static_cast<int>(Vect[i]));
    }
  }

  return IsOK;
}
Exemplo n.º 2
0
    void initParams(const openfluid::ware::WareParams_t& Params)
    {
      if (Params.find("part") != Params.end())
        m_PartStr = Params.at("part").toString();

      if (m_PartStr == "initparams")
        OPENFLUID_RaiseError(m_PartStr);
    }
bool PluggableSimulator::OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
                                                         const openfluid::ware::WareParamKey_t& ParamName,
                                                         long& Val) const
{
  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
    return it->second.toInteger(Val);

  return false;
}
bool PluggableSimulator::OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
                                                         const openfluid::ware::WareParamKey_t& ParamName,
                                                         openfluid::core::MatrixValue& Val) const
{
  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
    return it->second.toMatrixValue(Val.getStreamSeparator(1),Val.getStreamSeparator(2),Val);

  return false;
}
openfluid::core::StringValue PluggableSimulator::OPENFLUID_GetSimulatorParameter(
                                                 const openfluid::ware::WareParams_t& Params,
                                                 const openfluid::ware::WareParamKey_t& ParamName) const
{
  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
    return it->second;
  else
    throw openfluid::base::FrameworkException(computeFrameworkContext(OPENFLUID_CODE_LOCATION),
                                              "Parameter "+ParamName+ " does not exist");
}
bool PluggableSimulator::OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
                                                         const openfluid::ware::WareParamKey_t& ParamName,
                                                         openfluid::core::StringValue& Val) const
{
  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
  {
    Val = it->second;
    return true;
  }

  return false;
}
bool PluggableSimulator::OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
                                                         const openfluid::ware::WareParamKey_t& ParamName,
                                                         int& Val) const
{
  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
  {
    long TmpInt;

    if(it->second.toInteger(TmpInt))
    {
      Val = static_cast<int>(TmpInt);
      return true;
    }
  }

  return false;
}
bool PluggableSimulator::OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
                                                         const openfluid::ware::WareParamKey_t& ParamName,
                                                         float& Val) const
{
  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
  {
    double TmpDbl;

    if(it->second.toDouble(TmpDbl))
    {
      Val = static_cast<float>(TmpDbl);
      return true;
    }
  }

  return false;
}
bool PluggableSimulator::OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
                                                         const openfluid::ware::WareParamKey_t& ParamName,
                                                         std::vector<std::string>& Vals) const
{
  openfluid::ware::WareParams_t::const_iterator it = Params.find(ParamName);

  if (it != Params.end())
  {
    std::vector<std::string> Tokens;

    openfluid::tools::tokenizeString(it->second.data(),Tokens,";");

    Vals.clear();

    for (unsigned int i=0;i<Tokens.size();i++)
      Vals.push_back(Tokens[i]);

    return true;
  }

  return false;
}
bool PluggableSimulator::OPENFLUID_IsSimulatorParameterExist(const openfluid::ware::WareParams_t& Params,
                                                             const openfluid::ware::WareParamKey_t& ParamName) const
{
  return (Params.find(ParamName) != Params.end());
}