dbc-gen 0.1.7

A simple CAN database compiler
Documentation
use can_dbc::{
    AttributeDefault, AttributeDefinition, AttributeValue, AttributeValueForDatabase, AttributeValueType, ByteOrder, Comment, Dbc, Message, MessageId, MultiplexIndicator, Signal, Symbol, Transmitter, ValueType, Version
};
use dbc_gen::dbc_to_string;

pub fn main() {
    let dbc = Dbc {
        version: Version(String::from("")),
        new_symbols: vec![
            Symbol(String::from("NS_DESC_")),
            Symbol(String::from("CM_")),
            Symbol(String::from("BA_DEF_")),
            Symbol(String::from("BA_")),
            Symbol(String::from("VAL_")),
            Symbol(String::from("CAT_DEF_")),
            Symbol(String::from("CAT_")),
            Symbol(String::from("FILTER")),
            Symbol(String::from("BA_DEF_DEF_")),
            Symbol(String::from("EV_DATA_")),
            Symbol(String::from("ENVVAR_DATA_")),
            Symbol(String::from("SGTYPE_")),
            Symbol(String::from("SGTYPE_VAL_")),
            Symbol(String::from("BA_DEF_SGTYPE_")),
            Symbol(String::from("BA_SGTYPE_")),
            Symbol(String::from("SIG_TYPE_REF_")),
            Symbol(String::from("VAL_TABLE_")),
            Symbol(String::from("SIG_GROUP_")),
            Symbol(String::from("SIG_VALTYPE_")),
            Symbol(String::from("SIGTYPE_VALTYPE_")),
            Symbol(String::from("BO_TX_BU_")),
            Symbol(String::from("BA_DEF_REL_")),
            Symbol(String::from("BA_REL_")),
            Symbol(String::from("BA_DEF_DEF_REL_")),
            Symbol(String::from("BU_SG_REL_")),
            Symbol(String::from("BU_EV_REL_")),
            Symbol(String::from("BU_BO_REL_")),
            Symbol(String::from("SG_MUL_VAL_")),
        ],
        bit_timing: None,
        nodes: Vec::new(),
        value_tables: Vec::new(),
        messages: vec![
            Message {
                id: MessageId::Extended(0),
                name: String::from("zero"),
                size: 0,
                transmitter: Transmitter::VectorXXX,
                signals: vec![Signal {
                    name: String::from("zero"),
                    multiplexer_indicator: MultiplexIndicator::Plain,
                    start_bit: 0,
                    size: 0,
                    byte_order: ByteOrder::BigEndian,
                    value_type: ValueType::Unsigned,
                    factor: 0.0,
                    offset: 0.0,
                    min: 0.0,
                    max: 0.0,
                    unit: String::from("unit"),
                    receivers: vec![String::from("Vector__XXX")],
                }],
            },
            Message {
                id: MessageId::Extended(1),
                name: String::from("one"),
                size: 1,
                transmitter: Transmitter::VectorXXX,
                signals: vec![Signal {
                    name: String::from("one"),
                    multiplexer_indicator: MultiplexIndicator::Plain,
                    start_bit: 1,
                    size: 1,
                    byte_order: ByteOrder::BigEndian,
                    value_type: ValueType::Unsigned,
                    factor: 1.0,
                    offset: 1.0,
                    min: 1.0,
                    max: 1.0,
                    unit: String::from("unit"),
                    receivers: vec![String::from("Vector__XXX")],
                }],
            },
        ],
        message_transmitters: Vec::new(),
        environment_variables: Vec::new(),
        environment_variable_data: Vec::new(),
        signal_types: Vec::new(),
        comments: vec![
            Comment::Message {
                id: MessageId::Extended(0),
                comment: String::from("This is a test comment on message zero."),
            },
            Comment::Signal {
                message_id: MessageId::Extended(0),
                name: String::from("zero"),
                comment: String::from("This is a test comment on signal zero."),
            },
            Comment::Message {
                id: MessageId::Extended(1),
                comment: String::from("This is a test comment on message one."),
            },
            Comment::Signal {
                message_id: MessageId::Extended(1),
                name: String::from("one"),
                comment: String::from("This is a test comment on signal one."),
            },
        ],
        attribute_definitions: vec![
            AttributeDefinition::Plain(String::from("BusType"), AttributeValueType::String),
            AttributeDefinition::Plain(String::from("DatabaseCompiler"), AttributeValueType::String),
            AttributeDefinition::Plain(String::from("DatabaseVersion"), AttributeValueType::String),
            AttributeDefinition::Plain(String::from("ProtocolType"), AttributeValueType::String),
        ],
        relation_attribute_definitions: Vec::new(),
        attribute_defaults: vec![
            AttributeDefault { name: String::from("BusType"), value: AttributeValue::String(String::from("")) },
            AttributeDefault { name: String::from("DatabaseCompiler"), value: AttributeValue::String(String::from("")) },
            AttributeDefault { name: String::from("DatabaseVersion"), value: AttributeValue::String(String::from("0.1.0")) },
            AttributeDefault { name: String::from("ProtocolType"), value: AttributeValue::String(String::from("")) },
        ],
        relation_attribute_defaults: Vec::new(),
        relation_attribute_values: Vec::new(),
        attribute_values_database: vec![
            AttributeValueForDatabase { name: String::from("BusType"), value: AttributeValue::String(String::from("CAN")) },
            AttributeValueForDatabase { name: String::from("DatabaseCompiler"), value: AttributeValue::String(String::from("Kent Software (kent.software)")) },
            AttributeValueForDatabase { name: String::from("DatabaseVersion"), value: AttributeValue::String(String::from("1.0.0")) },
            AttributeValueForDatabase { name: String::from("ProtocolType"), value: AttributeValue::String(String::from("J1939")) },
        ],
        attribute_values_node: Vec::new(),
        attribute_values_message: Vec::new(),
        attribute_values_signal: Vec::new(),
        attribute_values_env: Vec::new(),
        value_descriptions: Vec::new(),
        signal_type_refs: Vec::new(),
        signal_groups: Vec::new(),
        signal_extended_value_type_list: Vec::new(),
        extended_multiplex: Vec::new(),
    };

    println!("{}", dbc_to_string(&dbc));
}