src/mesytec-mvlc/mvlc_readout_config.cc
/// Parses a CreateConfig from the given YAML input stream.
/// throws std::runtime_error on error.
Parses a CreateConfig from the given YAML input stream.
throws std::runtime_error on error.
Parses a CreateConfig from the given YAML input stream . throws std :: runtime_error on error .
CrateConfig crate_config_from_yaml(std::istream &input)
{
    CrateConfig result = {};
    YAML::Node yRoot = YAML::Load(input);
    if (!yRoot)
        throw std::runtime_error("CrateConfig YAML is empty");
    if (!yRoot["crate"])
        throw std::runtime_error("No 'crate' node found in YAML input");
    if (const auto &yCrate = yRoot["crate"])
    {
        if (const auto &yCon = yCrate["mvlc_connection"])
        {
            result.connectionType = connection_type_from_string(yCon["type"].as<std::string>());
            result.usbIndex = yCon["usbIndex"].as<int>();
            result.usbSerial = yCon["usbSerial"].as<std::string>();
            result.ethHost = yCon["ethHost"].as<std::string>();
            result.ethJumboEnable = yCon["ethJumboEnable"].as<bool>();
        }
        if (const auto &yStacks = yCrate["readout_stacks"])
        {
            for (const auto &yStack: yStacks)
                result.stacks.emplace_back(stack_command_builder_from_yaml(yStack));
        }
        if (const auto &yTriggers = yCrate["stack_triggers"])
        {
            for (const auto &yTrig: yTriggers)
                result.triggers.push_back(yTrig.as<u32>());
        }
        result.initTriggerIO = stack_command_builder_from_yaml(yCrate["init_trigger_io"]);
        result.initCommands = stack_command_builder_from_yaml(yCrate["init_commands"]);
        result.stopCommands = stack_command_builder_from_yaml(yCrate["stop_commands"]);
        if (yCrate["mcst_daq_start"])
            result.mcstDaqStart = stack_command_builder_from_yaml(yCrate["mcst_daq_start"]);
        if (yCrate["mcst_daq_stop"])
            result.mcstDaqStop = stack_command_builder_from_yaml(yCrate["mcst_daq_stop"]);
    }
    return result;
}
CrateConfig crate_config_from_yaml ( std :: istream & input ) { CrateConfig result = { } ; YAML :: Node yRoot = YAML :: Load ( input ) ; if ( ! yRoot ) throw std :: runtime_error ( " " ) ; if ( ! yRoot [ " " ] ) throw std :: runtime_error ( " " ) ; if ( const auto & yCrate = yRoot [ " " ] ) { if ( const auto & yCon = yCrate [ " " ] ) { result . connectionType = connection_type_from_string ( yCon [ " " ] . as < std :: string > ( ) ) ; result . usbIndex = yCon [ " " ] . as < int > ( ) ; result . usbSerial = yCon [ " " ] . as < std :: string > ( ) ; result . ethHost = yCon [ " " ] . as < std :: string > ( ) ; result . ethJumboEnable = yCon [ " " ] . as < bool > ( ) ; } if ( const auto & yStacks = yCrate [ " " ] ) { for ( const auto & yStack : yStacks ) result . stacks . emplace_back ( stack_command_builder_from_yaml ( yStack ) ) ; } if ( const auto & yTriggers = yCrate [ " " ] ) { for ( const auto & yTrig : yTriggers ) result . triggers . push_back ( yTrig . as < u32 > ( ) ) ; } result . initTriggerIO = stack_command_builder_from_yaml ( yCrate [ " " ] ) ; result . initCommands = stack_command_builder_from_yaml ( yCrate [ " " ] ) ; result . stopCommands = stack_command_builder_from_yaml ( yCrate [ " " ] ) ; if ( yCrate [ " " ] ) result . mcstDaqStart = stack_command_builder_from_yaml ( yCrate [ " " ] ) ; if ( yCrate [ " " ] ) result . mcstDaqStop = stack_command_builder_from_yaml ( yCrate [ " " ] ) ; } return result ; }
Parses a CreateConfig from the given YAML input stream.
Parses a CreateConfig from the given YAML input stream .
// The mcst nodes where not present initially. CrateConfigs generated // by older versions do not contain them.