void copy_DBR_CTRL(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure)
{
    const T* data = static_cast<const T*>(dbr);

    PVStructure::shared_pointer alarm = pvStructure->getStructureField("alarm");
    alarm->getIntField("status")->put(0);
    alarm->getIntField("severity")->put(data->severity);
    alarm->getStringField("message")->put(dbrStatus2alarmMessage[data->status]);

    PVStructure::shared_pointer disp = pvStructure->getStructureField("display");
    disp->getStringField("units")->put(std::string(data->units));
    disp->getDoubleField("limitHigh")->put(data->upper_disp_limit);
    disp->getDoubleField("limitLow")->put(data->lower_disp_limit);

    copy_format<T>(dbr, disp);

    PVStructure::shared_pointer va = pvStructure->getStructureField("valueAlarm");
    std::tr1::static_pointer_cast<sF>(va->getSubField("highAlarmLimit"))->put(data->upper_alarm_limit);
    std::tr1::static_pointer_cast<sF>(va->getSubField("highWarningLimit"))->put(data->upper_warning_limit);
    std::tr1::static_pointer_cast<sF>(va->getSubField("lowWarningLimit"))->put(data->lower_warning_limit);
    std::tr1::static_pointer_cast<sF>(va->getSubField("lowAlarmLimit"))->put(data->lower_alarm_limit);

    PVStructure::shared_pointer ctrl = pvStructure->getStructureField("control");
    ctrl->getDoubleField("limitHigh")->put(data->upper_ctrl_limit);
    ctrl->getDoubleField("limitLow")->put(data->lower_ctrl_limit);

    copy_DBR<pT, sT, sF, aF>(&data->value, count, pvStructure);
}
void copy_DBR_TIME(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure)
{
    const T* data = static_cast<const T*>(dbr);

    PVStructure::shared_pointer ts = pvStructure->getStructureField("timeStamp");
    epics::pvData::int64 spe = data->stamp.secPastEpoch;
    spe += 7305*86400;
    ts->getLongField("secondsPastEpoch")->put(spe);
    ts->getIntField("nanoseconds")->put(data->stamp.nsec);

    copy_DBR_STS<T, pT, sT, sF, aF>(dbr, count, pvStructure);
}
void copy_DBR_STS(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure)
{
    const T* data = static_cast<const T*>(dbr);

    PVStructure::shared_pointer alarm = pvStructure->getStructureField("alarm");
    // no mapping needed
    alarm->getIntField("status")->put(0);
    alarm->getIntField("severity")->put(data->severity);
    alarm->getStringField("message")->put(dbrStatus2alarmMessage[data->status]);

    copy_DBR<pT, sT, sF, aF>(&data->value, count, pvStructure);
}