Example #1
0
def protocol_const(code_path, mess_name_ids):
	file_name		= code_path + 'Msg.hpp'

	_str_msg_head	= '#ifndef _MSG_\n#define _MSG_\n\n#include <pb_type.hpp>\n\n\nclass Msg\n{\npublic:\n'
	_str_msg_end	= '};\n\n#endif\n'
	_str_msg_def	= 'static const U16 '
	_str_msg		= ''
	for mess_name_id in mess_name_ids:
		mess_name 	= mess_name_id['mess_name']
		mess_id 	= mess_name_id['mess_id']
		mess_note	= mess_name_id['mess_note']
		_str_msg += '\t// ' + mess_note + '\n\t' + (_str_msg_def + tool.cpp_proto_name_msg(mess_name)).ljust(55, chr(32)) + ' = ' + str(mess_id) + ';\n'

	_str_msg = _str_msg_head + _str_msg + _str_msg_end
	with open(file_name, 'w+') as fd:
		fd.write(_str_msg)
Example #2
0
def protocol_const(code_path, mess_name_ids):
    file_name = code_path + 'Msg.hpp'

    _str_msg_head = '#ifndef _MSG_\n#define _MSG_\n\n#include <pb_type.hpp>\n\n\nclass Msg\n{\npublic:\n'
    _str_msg_end = '};\n\n#endif\n'
    _str_msg_def = 'static const U16 '
    _str_msg = ''
    for mess_name_id in mess_name_ids:
        mess_name = mess_name_id['mess_name']
        mess_id = mess_name_id['mess_id']
        mess_note = mess_name_id['mess_note']
        _str_msg += '\t// ' + mess_note + '\n\t' + (
            _str_msg_def + tool.cpp_proto_name_msg(mess_name)).ljust(
                55, chr(32)) + ' = ' + str(mess_id) + ';\n'

    _str_msg = _str_msg_head + _str_msg + _str_msg_end
    with open(file_name, 'w+') as fd:
        fd.write(_str_msg)
Example #3
0
 def _set_class_name(self):
     self._str_msg_name = tool.cpp_proto_name_msg(self._mess_name)
     self._str_class_name = tool.cpp_class_name(self._mess_name)
     self._filename = self._code_path + self._str_class_name + '.cpp'
Example #4
0
	def _set_class_name(self):
		self._str_msg_name 	= tool.cpp_proto_name_msg(self._mess_name)
		self._str_class_name= tool.cpp_class_name(self._mess_name)
		self._filename		= self._code_path + self._str_class_name + '.cpp'