In this vignette, we are going to do an example analysis with MTConnect Data to show all the capabilities of the mtconnectR package
First let us define the raw data files that we are going to be working with. Two sets of example raw data and device XML files are provided along with the package
require(mtconnectR)
file_path_dmtcd = "extdata/test_dmtc_data_2.log"
file_path_xml = "extdata/test_devices_2.xml"
Before we read in the data into the MTC Device Class, it might help us a bit in understanding a bit about the raw data items. Let’s try to see how the Devices XML and the Raw data looks.
The devices XML has information about the configuration of one or more devices. We can check out the devices for which the info is present in the devices XML using the get_device_info_from_xml
function. From the device info, we can select the name of the device that we want to analyse further
(device_info = get_device_info_from_xml(system.file(file_path_xml, package = "mtconnectR")))
## id iso841Class name sampleInterval uuid
## 1 dev 6 VMC-3Axis 10 000
device_name = device_info$name[1]
The get_xpath_from_xml
function can read in the xpath info for a single device into a easily read data.frame format.
The data.frame contains the id and name of each data item and the xpath along with the type, category and subType of the data_item. It is easy to find out what are the data items of a particular type using this function. For example, we are going to find out the conditions data items which we will be using in the next step.
xpath_info = get_xpaths_from_xml(system.file(file_path_xml, package = "mtconnectR"), device_name)
conditions_data_items = xpath_info$id[xpath_info$category == "CONDITION"]