boost::optional<IdfObject> ForwardTranslator::translateExteriorLights(
    model::ExteriorLights& modelObject)
{
  IdfObject idfObject(IddObjectType::Exterior_Lights);

  m_idfObjects.push_back(idfObject);

  idfObject.setString(Exterior_LightsFields::Name, modelObject.name().get());

  OptionalIdfObject relatedIdfObject;

  model::Schedule schedule = modelObject.schedule();
  relatedIdfObject = translateAndMapModelObject(schedule);
  OS_ASSERT(relatedIdfObject);
  idfObject.setString(Exterior_LightsFields::ScheduleName,relatedIdfObject->name().get());

  model::ExteriorLightsDefinition definition = modelObject.exteriorLightsDefinition();

  double designLevel = definition.designLevel()*modelObject.multiplier();
  idfObject.setDouble(Exterior_LightsFields::DesignLevel,designLevel);

  if (!modelObject.isControlOptionDefaulted()) {
    idfObject.setString(Exterior_LightsFields::ControlOption,modelObject.controlOption());
  }

  if (!modelObject.isEndUseSubcategoryDefaulted()) {
    idfObject.setString(Exterior_LightsFields::EndUseSubcategory,modelObject.endUseSubcategory());
  }

  return idfObject;
}
boost::optional<IdfObject> ForwardTranslator::translateLights( Lights & modelObject )
{
  // create, register, and name object
  IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Lights,
                                                       modelObject);

  for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()){
    translateAndMapModelObject(lifeCycleCost);
  }

  LightsDefinition definition = modelObject.lightsDefinition();

  OptionalIdfObject relatedIdfObject;

  boost::optional<Space> space = modelObject.space();
  boost::optional<SpaceType> spaceType = modelObject.spaceType();
  if (space){
    boost::optional<ThermalZone> thermalZone = space->thermalZone();
    if (thermalZone){
      relatedIdfObject = translateAndMapModelObject(*thermalZone);
      OS_ASSERT(relatedIdfObject);
      idfObject.setString(LightsFields::ZoneorZoneListName,
                          relatedIdfObject->name().get());
    }
  }else if(spaceType){
    relatedIdfObject = translateAndMapModelObject(*spaceType);
    OS_ASSERT(relatedIdfObject);
    idfObject.setString(LightsFields::ZoneorZoneListName,
                        relatedIdfObject->name().get());
  }

  boost::optional<Schedule> schedule = modelObject.schedule();
  if (schedule){
    relatedIdfObject = translateAndMapModelObject(*schedule);
    OS_ASSERT(relatedIdfObject);
    idfObject.setString(LightsFields::ScheduleName, relatedIdfObject->name().get());
  }

  idfObject.setString(LightsFields::DesignLevelCalculationMethod, definition.designLevelCalculationMethod());

  double multiplier = modelObject.multiplier();

  boost::optional<double> d = definition.lightingLevel();
  if (d){
    idfObject.setDouble(LightsFields::LightingLevel, (*d)*multiplier);
  }

  d = definition.wattsperSpaceFloorArea();
  if (d){
    idfObject.setDouble(LightsFields::WattsperZoneFloorArea, (*d)*multiplier);
  }

  d = definition.wattsperPerson();
  if (d){
    idfObject.setDouble(LightsFields::WattsperPerson, (*d)*multiplier);
  }

  if (!definition.isReturnAirFractionDefaulted()){
    idfObject.setDouble(LightsFields::ReturnAirFraction, definition.returnAirFraction());
  }

  if (!definition.isFractionRadiantDefaulted()){
    idfObject.setDouble(LightsFields::FractionRadiant, definition.fractionRadiant());
  }

  if (!definition.isFractionVisibleDefaulted()){
    idfObject.setDouble(LightsFields::FractionVisible, definition.fractionVisible());
  }

  if (!modelObject.isFractionReplaceableDefaulted()){
    idfObject.setDouble(LightsFields::FractionReplaceable, modelObject.fractionReplaceable());
  }

  if (!modelObject.isEndUseSubcategoryDefaulted()){
    idfObject.setString(LightsFields::EndUseSubcategory, modelObject.endUseSubcategory());
  }

  if (!definition.isReturnAirFractionCalculatedfromPlenumTemperatureDefaulted()){
    if (definition.returnAirFractionCalculatedfromPlenumTemperature()){
      idfObject.setString(LightsFields::ReturnAirFractionCalculatedfromPlenumTemperature,"Yes");
    }else{
      idfObject.setString(LightsFields::ReturnAirFractionCalculatedfromPlenumTemperature,"No");
    }
  }

  if (!definition.isReturnAirFractionFunctionofPlenumTemperatureCoefficient1Defaulted()){
    idfObject.setDouble(LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1,
                        definition.returnAirFractionFunctionofPlenumTemperatureCoefficient1());
  }

  if (!definition.isReturnAirFractionFunctionofPlenumTemperatureCoefficient2Defaulted()){
    idfObject.setDouble(LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2,
                        definition.returnAirFractionFunctionofPlenumTemperatureCoefficient2());
  }

  return idfObject;
}