mirror of
https://github.com/nasa/fprime.git
synced 2025-12-15 14:05:24 -06:00
Downgrading Ubuntu to 18.0.4, saving progress now
This commit is contained in:
parent
98d1690a0e
commit
0dbb7662ef
@ -20,25 +20,8 @@
|
||||
<a:documentation>Name of the array.</a:documentation>
|
||||
<text/>
|
||||
</attribute>
|
||||
|
||||
<attribute name = "type">
|
||||
<a:documentation>Type of the array.</a:documentation>
|
||||
<text/>
|
||||
</attribute>
|
||||
|
||||
<attribute name = "size">
|
||||
<a:documentation>Size of the array.</a:documentation>
|
||||
<data type = "integer"></data>
|
||||
</attribute>
|
||||
|
||||
<!-- Optional attributes -->
|
||||
<optional>
|
||||
<attribute name = "string_size">
|
||||
<a:documentation>Optional string size in addition to required array size.</a:documentation>
|
||||
<text/>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
<!-- Optional attributes -->
|
||||
<optional>
|
||||
<attribute name = "namespace">
|
||||
<a:documentation>Namespace of the serializable object.</a:documentation>
|
||||
@ -46,57 +29,74 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
<optional>
|
||||
<attribute name = "format">
|
||||
<a:documentation>Used to format data into readable content on the ground system software.</a:documentation>
|
||||
<text/>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
<optional>
|
||||
<attribute name = "typeid">
|
||||
<a:documentation>ID for the object. If not declared, isfgen autogenerates one. Must be unique across all serlializable files.</a:documentation>
|
||||
<ref name = "id_define"></ref>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
|
||||
<!-- Elements -->
|
||||
<element name = "default">
|
||||
<oneOrMore>
|
||||
<element name = "value">
|
||||
<text/>
|
||||
<interleave>
|
||||
<element name = "format">
|
||||
<a:documentation>Used to format data into readable content on the ground system software.</a:documentation>
|
||||
<text/>
|
||||
</element>
|
||||
|
||||
<element name = "type">
|
||||
<optional>
|
||||
<attribute name = "string_size">
|
||||
<a:documentation>Optional string size in addition to required array size.</a:documentation>
|
||||
<data type = "integer"></data>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
<optional>
|
||||
<attribute name = "typeid">
|
||||
<a:documentation>ID for the object. If not declared, isfgen autogenerates one. Must be unique across all array files.</a:documentation>
|
||||
<ref name = "id_define"></ref>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
<a:documentation>Type of the array.</a:documentation>
|
||||
<text/>
|
||||
</element>
|
||||
|
||||
<element name = "size">
|
||||
<a:documentation>Size of the array.</a:documentation>
|
||||
<data type = "integer"></data>
|
||||
</element>
|
||||
|
||||
<element name = "default">
|
||||
<oneOrMore>
|
||||
<element name = "value">
|
||||
<text/>
|
||||
</element>
|
||||
</oneOrMore>
|
||||
</element>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name = "include_header">
|
||||
<a:documentation>Defines the header file of the interface.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</oneOrMore>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name = "include_header">
|
||||
<a:documentation>Defines the header file of the interface.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
<zeroOrMore>
|
||||
<element name = "import_serializable_type">
|
||||
<a:documentation>Imports serializable types.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name = "import_serializable_type">
|
||||
<a:documentation>Imports serializable types.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
<zeroOrMore>
|
||||
<element name = "import_enum_type">
|
||||
<a:documentation>Imports enum types.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name = "import_enum_type">
|
||||
<a:documentation>Imports enum types.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
|
||||
<zeroOrMore>
|
||||
<element name = "import_array_type">
|
||||
<a:documentation>Import array XML files.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
<zeroOrMore>
|
||||
<element name = "import_array_type">
|
||||
<a:documentation>Import array XML files.</a:documentation>
|
||||
<data type="anyURI"></data>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
</grammar>
|
||||
|
||||
9
Autocoders/Python/schema/default/array_schematron.rng
Normal file
9
Autocoders/Python/schema/default/array_schematron.rng
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema
|
||||
xmlns="http://purl.oclc.org/dsdl/schematron">
|
||||
<pattern id = "DEFAULT_VALUES">
|
||||
<rule context="array">
|
||||
<assert test="count(current()/default/value) <= current()/size">Size greater than number of default values.</assert>
|
||||
</rule>
|
||||
</pattern>
|
||||
</schema>
|
||||
@ -165,7 +165,14 @@ namespace ${namespace} {
|
||||
|
||||
void ${name}::toString(Fw::StringBase& text) const {
|
||||
|
||||
static const char * formatString = "${format}";
|
||||
static const char * formatString = "["
|
||||
#for $index in $range(0, $size):
|
||||
#if $index != $size - 1:
|
||||
"[${format}], "
|
||||
#else:
|
||||
"[${format}] ]";
|
||||
#end if
|
||||
#end for
|
||||
|
||||
// declare strings to hold any serializable toString() arguments
|
||||
|
||||
@ -190,11 +197,7 @@ void ${name}::toString(Fw::StringBase& text) const {
|
||||
|
||||
\#ifdef BUILD_UT
|
||||
std::ostream& operator<<(std::ostream& os, const ${name}& obj) {
|
||||
os << "[";
|
||||
for (U32 i = 0; i < Array::SIZE; ++i) {
|
||||
os << " " << obj[i];
|
||||
}
|
||||
os << "]";
|
||||
os << obj::toString();
|
||||
return os;
|
||||
}
|
||||
\#endif
|
||||
|
||||
@ -66,12 +66,12 @@ namespace ${namespace} {
|
||||
);
|
||||
|
||||
//! Construct a ${name} and initialize its elements from elements
|
||||
${name}(
|
||||
${name}(
|
||||
#for $i in $range(1, $size + 1):
|
||||
#if $i != $size:
|
||||
const ElementType (&e${i}), //!< Element ${i}
|
||||
#else
|
||||
const ElementType (&e${i}) //!< Element ${i}
|
||||
const ElementType (&e${i}), //!< Element ${i}
|
||||
#else:
|
||||
const ElementType (&e${i})
|
||||
#end if
|
||||
#end for
|
||||
);
|
||||
|
||||
@ -63,11 +63,13 @@ class XmlArrayParser(object):
|
||||
# List of XML array type files
|
||||
self.__include_array_files = []
|
||||
|
||||
self.__format = ""
|
||||
self.__format = None
|
||||
self.__type_id = None
|
||||
self.__string_size = None
|
||||
self.__type = None
|
||||
self.__size = None
|
||||
self.__default = []
|
||||
self.__xml_filename = xml_file
|
||||
self.__type = "U32"
|
||||
self.__size = "4"
|
||||
|
||||
self.Config = ConfigManager.ConfigManager.getInstance()
|
||||
|
||||
@ -90,6 +92,8 @@ class XmlArrayParser(object):
|
||||
# 2/3 conversion
|
||||
if not relax_compiled.validate(element_tree):
|
||||
raise FprimeRngXmlValidationException(relax_compiled.error_log)
|
||||
|
||||
self.validate_xml(xml_file, element_tree, 'schematron', 'array_default')
|
||||
|
||||
array = element_tree.getroot()
|
||||
if array.tag != "array":
|
||||
@ -101,24 +105,19 @@ class XmlArrayParser(object):
|
||||
|
||||
if 'namespace' in array.attrib:
|
||||
self.__namespace = array.attrib['namespace']
|
||||
else:
|
||||
self.__namespace = None
|
||||
|
||||
if 'format' in array.attrib:
|
||||
self.__format = array.attrib['format']
|
||||
else:
|
||||
self.__format = None
|
||||
|
||||
if 'typeid' in array.attrib:
|
||||
self.__type_id = array.attrib['typeid']
|
||||
else:
|
||||
self.__type_id = None
|
||||
|
||||
self.__type = array.attrib["type"]
|
||||
self.__size = int(array.attrib["size"])
|
||||
|
||||
for array_tag in array:
|
||||
if array_tag.tag == 'default':
|
||||
if array_tag.tag == 'format':
|
||||
self.__format = array_tag.text
|
||||
elif array_tag.tag == 'type':
|
||||
self.__type = array_tag.text
|
||||
if 'string_size' in array_tag.attrib:
|
||||
self.__string_size = array_tag['string_size']
|
||||
elif array_tag.tag == 'typeid':
|
||||
self.__type_id = array_tag.text
|
||||
elif array_tag.tag == 'size':
|
||||
self.__size = array_tag.text
|
||||
elif array_tag.tag == 'default':
|
||||
for value_tag in array_tag:
|
||||
self.__default.append(value_tag.text)
|
||||
elif array_tag.tag == 'include_header':
|
||||
@ -140,6 +139,30 @@ class XmlArrayParser(object):
|
||||
n = h.hexdigest()
|
||||
self.__type_id = "0x" + n.upper()[-8:]
|
||||
|
||||
def validate_xml(self, dict_file, parsed_xml_tree, validator_type, validator_name):
|
||||
# Check that validator is valid
|
||||
if not validator_type in self.Config or not validator_name in self.Config[validator_type]:
|
||||
msg = "XML Validator type " + validator_type + " not found in ConfigManager instance"
|
||||
raise FprimeXmlException(msg)
|
||||
|
||||
# Create proper xml validator tool
|
||||
validator_file_handler = open(ROOTDIR + self.Config.get(validator_type, validator_name), 'r')
|
||||
validator_parsed = etree.parse(validator_file_handler)
|
||||
validator_file_handler.close()
|
||||
if validator_type == 'schema':
|
||||
validator_compiled = etree.RelaxNG(validator_parsed)
|
||||
elif validator_type == 'schematron':
|
||||
validator_compiled = isoschematron.Schematron(validator_parsed)
|
||||
|
||||
# Validate XML file
|
||||
if not validator_compiled.validate(parsed_xml_tree):
|
||||
if validator_type == 'schema':
|
||||
msg = "XML file {} is not valid according to {} {}.".format(dict_file, validator_type, ROOTDIR + self.Config.get(validator_type, validator_name))
|
||||
raise FprimeXmlException(msg)
|
||||
elif validator_type == 'schematron':
|
||||
msg = "WARNING: XML file {} is not valid according to {} {}.".format(dict_file, validator_type, ROOTDIR + self.Config.get(validator_type, validator_name))
|
||||
PRINT.info(msg)
|
||||
|
||||
def get_name(self):
|
||||
return self.__name
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ def generate_array(xml_file):
|
||||
name = array_xml.get_name()
|
||||
namespace = array_xml.get_namespace()
|
||||
arr_type = array_xml.get_type()
|
||||
arr_size = array_xml.get_size()
|
||||
arr_size = int(array_xml.get_size())
|
||||
format_string = array_xml.get_format()
|
||||
default_values = array_xml.get_default()
|
||||
type_id = array_xml.get_type_id()
|
||||
|
||||
@ -130,6 +130,7 @@ class ConfigManager(parent):
|
||||
self.__prop['schematron']["top_unique"] = '/Autocoders/Python/schema/default/top_uniqueness_schematron.rng'
|
||||
self.__prop['schematron']["active_comp"] = '/Autocoders/Python/schema/default/active_comp_schematron.rng'
|
||||
self.__prop['schematron']["enum_value"] = '/Autocoders/Python/schema/default/enum_value_schematron.rng'
|
||||
self.__prop['schematron']["array_default"] = '/Autocoders/Python/schema/default/array_schematron.rng'
|
||||
self._setSectionDefaults('schematron')
|
||||
################################################################
|
||||
# component parameters here.
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
# Broken topology
|
||||
#add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/app1")
|
||||
#add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/app2")
|
||||
#add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/array_xml")
|
||||
#add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/cnt_only")
|
||||
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/command_multi_inst")
|
||||
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/command_res")
|
||||
|
||||
13
Autocoders/Python/test/array_xml/ArrayTypeArrayAi.xml
Normal file
13
Autocoders/Python/test/array_xml/ArrayTypeArrayAi.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-model href="../../Autocoders/Python/schema/default/array_schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
|
||||
<array name="ArrayType" namespace="ArrayNS">
|
||||
<import_array_type>Autocoders/Python/test/array_xml/InternalTypeArrayAi.xml</import_array_type>
|
||||
|
||||
<type>InternalType</type>
|
||||
<size>1</size>
|
||||
<format>%s</format>
|
||||
|
||||
<default>
|
||||
<value>ArrayNS::InternalType(1,2,3,4)</value>
|
||||
</default>
|
||||
</array>
|
||||
21
Autocoders/Python/test/array_xml/CMakeLists.txt
Normal file
21
Autocoders/Python/test/array_xml/CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
# Default module cmake file
|
||||
# AUTOCODER_INPUT_FILES: Contains all Autocoder input files
|
||||
# SOURCE_FILES: Handcoded C++ source files)
|
||||
|
||||
set(SOURCE_FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Enum1EnumAi.xml"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Serial1SerializableAi.xml"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Port1PortAi.xml"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Component1ComponentAi.xml"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ExampleEnumImpl.cpp"
|
||||
)
|
||||
register_fprime_module()
|
||||
set(SOURCE_FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/test/ut/main.cpp"
|
||||
)
|
||||
set(EXECUTABLE_NAME "Autocoders_Python_test_array_xml_ut_exe")
|
||||
set(MOD_DEPS
|
||||
"${CMAKE_CURRENT_LIST_DIR}")
|
||||
register_fprime_executable()
|
||||
|
||||
|
||||
15
Autocoders/Python/test/array_xml/Component1ComponentAi.xml
Normal file
15
Autocoders/Python/test/array_xml/Component1ComponentAi.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-model href="../../Autocoders/Python/schema/ISF/component_schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
|
||||
<component name="Component1" kind="active" namespace="Example">
|
||||
<import_array_type>Autocoders/Python/test/array_xml/ArrayTypeArrayAi.xml</import_array_type>
|
||||
<import_array_type>Autocoders/Python/test/array_xml/InternalTypeArrayAi.xml</import_array_type>
|
||||
<import_port_type>Autocoders/Python/test/array_xml/Port1PortAi.xml</import_port_type>
|
||||
<import_serializable_type>Autocoders/Python/test/array_xml/Serial1SerializableAi.xml</import_serializable_type>
|
||||
|
||||
<comment>A demonstration component with arrays</comment>
|
||||
<ports>
|
||||
<port name="ExEnumIn" kind="async_input" data_type="Example::Port1" max_number="1"/>
|
||||
<port name="EnumIn" kind="async_input" data_type="Example::Port1" max_number="1"/>
|
||||
<port name="EnumOut" kind="output" data_type="Example::Port1" max_number="1"/>
|
||||
</ports>
|
||||
</component>
|
||||
29
Autocoders/Python/test/array_xml/ExampleArrayImpl.cpp
Normal file
29
Autocoders/Python/test/array_xml/ExampleArrayImpl.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include <Autocoders/Python/test/array_xml/ExampleArrayImpl.hpp>
|
||||
#include <Fw/Types/BasicTypes.hpp>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Example {
|
||||
|
||||
ExampleArrayImpl::ExampleArrayImpl(const char* compName) : Component1ComponentBase(compName) {
|
||||
}
|
||||
|
||||
ExampleArrayImpl::~ExampleArrayImpl(void) {
|
||||
|
||||
}
|
||||
|
||||
void ExampleArrayImpl::init(NATIVE_INT_TYPE queueDepth) {
|
||||
Component1ComponentBase::init(queueDepth);
|
||||
}
|
||||
|
||||
void ExampleArrayImpl::ExArrayIn_handler(NATIVE_INT_TYPE portNum, ArrayNS::ArrayType array1, Example::Serial1 serial1) {
|
||||
printf("%s Invoked ExArrayIn_handler();\n%s", this->getObjName(), this->toString());
|
||||
this->ArrayOut_out(0, array1, serial1);
|
||||
}
|
||||
|
||||
void ExampleArrayImpl::ArrayIn_handler(NATIVE_INT_TYPE portNum, ArrayNS::ArrayType array1, Example::Serial1 serial1) {
|
||||
printf("%s Invoked ArrayIn_handler();\n%s", this->getObjName(), portNum, this->toString());
|
||||
}
|
||||
};
|
||||
23
Autocoders/Python/test/array_xml/ExampleArrayImpl.hpp
Normal file
23
Autocoders/Python/test/array_xml/ExampleArrayImpl.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef EXAMPLE_ARRAY_IMPL_HPP
|
||||
#define EXAMPLE_ARRAY_IMPL_HPP
|
||||
|
||||
#include <Autocoders/Python/test/array_xml/Component1ComponentAc.hpp>
|
||||
|
||||
namespace Example {
|
||||
|
||||
class ExampleArrayImpl : public Component1ComponentBase {
|
||||
public:
|
||||
|
||||
// Only called by derived class
|
||||
ExampleArrayImpl(const char* compName);
|
||||
~ExampleArrayImpl(void);
|
||||
void init(NATIVE_INT_TYPE queueDepth);
|
||||
|
||||
private:
|
||||
void ExArrayIn_handler(NATIVE_INT_TYPE portNum, ArrayNS::ArrayType array1, Example::Serial1 serial1);
|
||||
void ArrayIn_handler(NATIVE_INT_TYPE portNum, ArrayNS::ArrayType array1, Example::Serial1 serial1);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
13
Autocoders/Python/test/array_xml/InternalTypeArrayAi.xml
Normal file
13
Autocoders/Python/test/array_xml/InternalTypeArrayAi.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-model href="../../Autocoders/Python/schema/default/array_schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
|
||||
<array name="InternalType" namespace="ArrayNS">
|
||||
<type>U32</type>
|
||||
<size>4</size>
|
||||
<format>%u</format>
|
||||
|
||||
<default>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
</default>
|
||||
</array>
|
||||
16
Autocoders/Python/test/array_xml/Makefile
Normal file
16
Autocoders/Python/test/array_xml/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
# This Makefile goes in each module, and allows building of an individual module library.
|
||||
# It is expected that each developer will add targets of their own for building and running
|
||||
# tests, for example.
|
||||
|
||||
# derive module name from directory
|
||||
DEPLOYMENT = Top
|
||||
|
||||
MODULE_DIR = Autocoders/Python/test/array_xml
|
||||
MODULE = $(subst /,,$(MODULE_DIR))
|
||||
|
||||
BUILD_ROOT ?= $(subst /$(MODULE_DIR),,$(CURDIR))
|
||||
export BUILD_ROOT
|
||||
|
||||
include $(BUILD_ROOT)/mk/makefiles/module_targets.mk
|
||||
|
||||
# Add module specific targets here
|
||||
20
Autocoders/Python/test/array_xml/Port1PortAi.xml
Normal file
20
Autocoders/Python/test/array_xml/Port1PortAi.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?oxygen RNGSchema="file:../xml/ISF_Type_Schema.rnc" type="compact"?>
|
||||
<interface name="Port1" namespace="Example">
|
||||
<import_array_type>Autocoders/Python/test/array_xml/ArrayTypeArrayAi.xml</import_array_type>
|
||||
<import_array_type>Autocoders/Python/test/array_xml/InternalTypeArrayAi.xml</import_array_type>
|
||||
|
||||
<import_serializable_type>Autocoders/Python/test/enum_xml/Serial1SerializableAi.xml</import_serializable_type>
|
||||
<comment>
|
||||
Example port with arg
|
||||
</comment>
|
||||
<args>
|
||||
<arg name="Arg1" type="ArrayNS::ArrayType">
|
||||
<comment>Example array arg</comment>
|
||||
</arg>
|
||||
<arg name="Arg2" type="Example::Serial1">
|
||||
<comment>Example serial arg w enum</comment>
|
||||
</arg>
|
||||
</args>
|
||||
</interface>
|
||||
|
||||
15
Autocoders/Python/test/array_xml/Serial1SerializableAi.xml
Normal file
15
Autocoders/Python/test/array_xml/Serial1SerializableAi.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?oxygen RNGSchema="file:../../Autocoders/Python/schema/ISF_Type_Schema.rnc" type="compact"?>
|
||||
<serializable namespace="Example" name="Serial1">
|
||||
<import_array_type>Autocoders/Python/test/array_xml/InternalTypeArrayAi.xml</import_array_type>
|
||||
<comment>
|
||||
Some Example Members
|
||||
</comment>
|
||||
<members>
|
||||
<member name="Member1" type="U32" comment = "Example member 1"/>
|
||||
<member name="Member2" type="U32" comment = "Example member 2"/>
|
||||
<member name="Member3" type="ArrayNS::InternalType" comment = "Example array member">
|
||||
</member>
|
||||
</members>
|
||||
</serializable>
|
||||
|
||||
23
Autocoders/Python/test/array_xml/mod.mk
Normal file
23
Autocoders/Python/test/array_xml/mod.mk
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
# Copyright 2004-2008, by the California Institute of Technology.
|
||||
# ALL RIGHTS RESERVED. United States Government Sponsorship
|
||||
# acknowledged.
|
||||
#
|
||||
#
|
||||
|
||||
#This is a template for the mod.mk file that goes in each module
|
||||
# and each module's subdirectories.
|
||||
# With a fresh checkout, "make gen_make" should be invoked. It should also be
|
||||
# run if any of the variables are updated. Any unused variables can
|
||||
# be deleted from the file.
|
||||
|
||||
# There are some standard files that are included for reference
|
||||
|
||||
SRC = Component1ComponentAi.xml \
|
||||
ArrayTypeArrayAi.xml \
|
||||
InternalTypeArrayAi.xml \
|
||||
Port1PortAi.xml \
|
||||
Serial1SerializableAi.xml
|
||||
|
||||
|
||||
SUBDIRS = test
|
||||
17
Autocoders/Python/test/array_xml/test/mod.mk
Normal file
17
Autocoders/Python/test/array_xml/test/mod.mk
Normal file
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright 2004-2008, by the California Institute of Technology.
|
||||
# ALL RIGHTS RESERVED. United States Government Sponsorship
|
||||
# acknowledged.
|
||||
#
|
||||
#
|
||||
|
||||
# This is a template for the mod.mk file that goes in each module
|
||||
# and each module's subdirectories.
|
||||
# With a fresh checkout, "make gen_make" should be invoked. It should also be
|
||||
# run if any of the variables are updated. Any unused variables can
|
||||
# be deleted from the file.
|
||||
|
||||
# There are some standard files that are included for reference
|
||||
|
||||
SUBDIRS = ut
|
||||
|
||||
150
Autocoders/Python/test/array_xml/test/ut/main.cpp
Normal file
150
Autocoders/Python/test/array_xml/test/ut/main.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
#include <Autocoders/Python/test/enum_xml/Component1ComponentAc.hpp>
|
||||
#include <Autocoders/Python/test/enum_xml/InternalTypeArrayAc.hpp>
|
||||
#include <Autocoders/Python/test/enum_xml/ArrayTypeArrayAc.hpp>
|
||||
#include <Autocoders/Python/test/enum_xml/Port1PortAc.hpp>
|
||||
#include <Autocoders/Python/test/enum_xml/Serial1SerializableAc.hpp>
|
||||
|
||||
#include <Autocoders/Python/test/enum_xml/ExampleArrayImpl.hpp>
|
||||
|
||||
#include <Fw/Obj/SimpleObjRegistry.hpp>
|
||||
#include <Fw/Types/SerialBuffer.hpp>
|
||||
#include <Fw/Types/Assert.hpp>
|
||||
|
||||
#include <bitset>
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Registry
|
||||
static Fw::SimpleObjRegistry* simpleReg_ptr = 0;
|
||||
|
||||
// Component instance pointers
|
||||
Example::ExampleArrayImpl* inst1 = 0;
|
||||
Example::ExampleArrayImpl* inst2 = 0;
|
||||
|
||||
extern "C" {
|
||||
void dumparch(void);
|
||||
void dumpobj(const char* objName);
|
||||
}
|
||||
|
||||
#ifdef TGT_OS_TYPE_LINUX
|
||||
extern "C" {
|
||||
int main(int argc, char* argv[]);
|
||||
};
|
||||
#endif
|
||||
|
||||
void dumparch(void) {
|
||||
simpleReg_ptr->dump();
|
||||
}
|
||||
|
||||
void dumpobj(const char* objName) {
|
||||
simpleReg_ptr->dump(objName);
|
||||
}
|
||||
|
||||
void constructArchitecture(void) {
|
||||
Fw::PortBase::setTrace(true);
|
||||
|
||||
simpleReg_ptr = new Fw::SimpleObjRegistry();
|
||||
|
||||
// Instantiate the inst1 and inst2
|
||||
inst1 = new Example::ExampleArrayImpl("inst1");
|
||||
inst2 = new Example::ExampleArrayImpl("inst2");
|
||||
|
||||
// Connect inst1 to inst2
|
||||
inst1->set_ArrayOut_OutputPort(0, inst2->get_ArrayIn_InputPort(0));
|
||||
|
||||
// Connect inst2 to inst1
|
||||
inst2->set_ArrayOut_OutputPort(0, inst1->get_ArrayIn_InputPort(0));
|
||||
|
||||
// Instantiate components
|
||||
inst1->init(100);
|
||||
inst2->init(100);
|
||||
inst1->start(0, 100, 10 * 1024);
|
||||
inst2->start(0, 100, 10 * 1024);
|
||||
|
||||
dumparch();
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Construct the topology here.
|
||||
constructArchitecture();
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
cout << "Initialize Arrays";
|
||||
|
||||
ArrayNS::InternalType array1 = ArrayNS::InternalType(6,7,120,444);
|
||||
ArrayNS::ArrayType array2 = ArrayNS::ArrayType(array1);
|
||||
Example::Serial1 serial1;
|
||||
|
||||
// Serialize arrays
|
||||
cout << "Serialize arrays";
|
||||
U8 buffer1[1024];
|
||||
U8 buffer2[1024];
|
||||
|
||||
Fw::SerialBuffer arraySerial1 = Fw::SerialBuffer(buffer1, sizeof(buffer1));
|
||||
Fw::SerialBuffer arraySerial2 = Fw::SerialBuffer(buffer2, sizeof(buffer2));
|
||||
|
||||
if (arraySerial1.serialize(array1) != Fw::FW_SERIALIZE_OK) {
|
||||
cout << "ERROR: bad serialization array1." << endl;
|
||||
} else {
|
||||
cout << "Serialized array1" << endl;
|
||||
}
|
||||
|
||||
if (arraySerial2.serialize(array2) != Fw::FW_SERIALIZE_OK) {
|
||||
cout << "ERROR: bad serialization array2." << endl;
|
||||
} else {
|
||||
cout << "Serialized array2" << endl;
|
||||
}
|
||||
|
||||
cout << "Serialized enums" << endl;
|
||||
}
|
||||
|
||||
cout << "Deserializing enums";
|
||||
if (arraySerial1.deserialize(array1Save) != Fw::FW_SERIALIZE_OK) {
|
||||
cout << "ERROR: bad deserialization array1." << endl;
|
||||
} else {
|
||||
cout << "Deserialized array1" << endl;
|
||||
}
|
||||
if(arraySerial2.deserialize(array2Save) != Fw::FW_SERIALIZE_OK) {
|
||||
cout << "ERROR: bad deserialization array2." << endl;
|
||||
} else {
|
||||
cout << "Deserialized array2" << endl;
|
||||
}
|
||||
|
||||
cout << "Deserialized arrays" << endl;
|
||||
|
||||
// Create serializable
|
||||
serial1 = Example::Serial1(100, 100000, array2);
|
||||
|
||||
// Invoke ports to test enum usage
|
||||
cout << "Invoking input ports..." << endl;
|
||||
cout << "Invoking inst1..." << endl;
|
||||
inst1->get_ExEnumIn_InputPort(0)->invoke(array1, serial1);
|
||||
|
||||
// Wait for port handler to execute
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
cout << "Invoking inst2..." << endl;
|
||||
inst2->get_ExEnumIn_InputPort(0)->invoke(array1, serial1);
|
||||
|
||||
// Wait for port handler to execute
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
cout << "Invoked ports" << endl;
|
||||
|
||||
cout << "Quitting..." << endl;
|
||||
|
||||
cout << "Deleting components..." << endl;
|
||||
delete inst1;
|
||||
delete inst2;
|
||||
cout << "Delete registration objects..." << endl;
|
||||
delete simpleReg_ptr;
|
||||
cout << "Completed..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
18
Autocoders/Python/test/array_xml/test/ut/mod.mk
Normal file
18
Autocoders/Python/test/array_xml/test/ut/mod.mk
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright 2004-2008, by the California Institute of Technology.
|
||||
# ALL RIGHTS RESERVED. United States Government Sponsorship
|
||||
# acknowledged.
|
||||
#
|
||||
#
|
||||
|
||||
# This is a template for the mod.mk file that goes in each module
|
||||
# and each module's subdirectories.
|
||||
# With a fresh checkout, "make gen_make" should be invoked. It should also be
|
||||
# run if any of the variables are updated. Any unused variables can
|
||||
# be deleted from the file.
|
||||
|
||||
# There are some standard files that are included for reference
|
||||
|
||||
TEST_SRC = Handcode/GTestBase.cpp Handcode/TesterBase.cpp Tester.cpp main.cpp
|
||||
|
||||
TEST_MODS = Autocoders/Python/test/command2 Fw/Cmd Fw/Comp Fw/Port Fw/Prm Fw/Time Fw/Tlm Fw/Types Fw/Log Fw/Obj Os Fw/Com gtest
|
||||
@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-model href="../../Autocoders/Python/schema/default/array_schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
|
||||
<array name="ArrayType" type="U32" size="2">
|
||||
<array name="ArrayType">
|
||||
<type>U32</type>
|
||||
<size>2</size>
|
||||
<format>%u</format>
|
||||
|
||||
<default>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user