KaCanOpen
 All Classes Functions Variables Typedefs Enumerations Pages
eds_library.h
1 /*
2  * Copyright (c) 2015, Thomas Keh
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #pragma once
33 
34 #include <unordered_map>
35 
36 #include "entry.h"
37 #include "address.h"
38 
39 namespace kaco {
40 
41  class Device;
42 
46  class EDSLibrary {
47 
48  public:
49 
53  EDSLibrary(std::unordered_map<Address, Entry>& dictionary, std::unordered_map<std::string, Address>& name_to_address);
54 
58  bool lookup_library(std::string path = "");
59 
63 
67  bool load_default_eds(uint16_t device_profile_number);
68 
75  bool load_manufacturer_eds_deprecated(uint32_t vendor_id, uint32_t product_code, uint32_t revision_number);
76 
80  bool load_manufacturer_eds(Device& device);
81 
84  bool ready() const;
85 
87  void reset_dictionary();
88 
90  std::string get_most_recent_eds_file_path() const;
91 
92  private:
93 
95  static const bool debug = false;
96 
98  std::unordered_map<Address, Entry>& m_dictionary;
99 
101  std::unordered_map<std::string, Address>& m_name_to_address;
102 
104  std::string m_library_path;
105 
107  bool m_ready;
108 
110  std::string most_recent_eds_file;
111 
112  };
113 
114 } // end namespace kaco
bool load_default_eds(uint16_t device_profile_number)
Loads entries defined in generic CiA profile EDS files.
bool load_mandatory_entries()
Loads mandatory dictionary entries defined in CiA 301 standard.
Definition: eds_library.cpp:96
bool lookup_library(std::string path="")
Finds EDS library on disk.
Definition: eds_library.cpp:61
bool load_manufacturer_eds(Device &device)
Loads entries defined in device specific EDS files proviced by manufacturers.
This class represents a CanOpen slave device in the network.
Definition: device.h:83
This class provides access to KaCanOpen's EDS library. It manages device specific as well as generic ...
Definition: eds_library.h:46
bool ready() const
Checks if lookup_library() was successful.
void reset_dictionary()
Resets the dictionary and the name-address mapping.
EDSLibrary(std::unordered_map< Address, Entry > &dictionary, std::unordered_map< std::string, Address > &name_to_address)
Constructor.
Definition: eds_library.cpp:57
std::string get_most_recent_eds_file_path() const
Returns the path to the most recently loaded EDS file.
bool load_manufacturer_eds_deprecated(uint32_t vendor_id, uint32_t product_code, uint32_t revision_number)
Loads entries defined in device specific EDS files proviced by manufacturers.