Commit db1cf79b authored by captainwong's avatar captainwong

inline

parent 65dd613b
...@@ -145,6 +145,13 @@ ...@@ -145,6 +145,13 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="gen_event_md.cpp" /> <ClCompile Include="gen_event_md.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ademco_detail.h" />
<ClInclude Include="..\..\include\ademco_event.h" />
<ClInclude Include="..\..\include\ademco_packet.h" />
<ClInclude Include="..\..\include\hb_detail.h" />
<ClInclude Include="..\..\include\hb_helper.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
......
...@@ -19,4 +19,21 @@ ...@@ -19,4 +19,21 @@
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ademco_detail.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ademco_event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ademco_packet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\hb_detail.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\hb_helper.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -100,6 +100,11 @@ ...@@ -100,6 +100,11 @@
<LibraryDependencies>event_core;event_pthreads;pthread;rt;%(LibraryDependencies)</LibraryDependencies> <LibraryDependencies>event_core;event_pthreads;pthread;rt;%(LibraryDependencies)</LibraryDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" /> <ImportGroup Label="ExtensionTargets" />
</Project> </Project>
\ No newline at end of file
...@@ -22,4 +22,7 @@ ...@@ -22,4 +22,7 @@
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClCompile Include="..\server_demo_libevent\server_demo_libevent.cpp" />
</ItemGroup>
</Project> </Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<RemoteTarget>-2055866198;192.168.1.166 (username=, port=22, authentication=Password)</RemoteTarget> <RemoteTarget>-2108636259;192.168.1.168 (username=, port=22, authentication=Password)</RemoteTarget>
<RemoteDebuggerCommand>server_demo_libevent_linux</RemoteDebuggerCommand> <RemoteDebuggerCommand>server_demo_libevent_linux</RemoteDebuggerCommand>
<RemoteDebuggerWorkingDirectory>/root/vsprojects/server_demo_libevent_linux/examples/server_demo_libevent_linux/bin/x64/Debug</RemoteDebuggerWorkingDirectory> <RemoteDebuggerWorkingDirectory>/root/vsprojects/server_demo_libevent_linux/examples/server_demo_libevent_linux/bin/x64/Debug</RemoteDebuggerWorkingDirectory>
<DebuggerFlavor>LinuxDebugger</DebuggerFlavor> <DebuggerFlavor>LinuxDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<RemoteTarget>-2108636259;192.168.1.168 (username=, port=22, authentication=Password)</RemoteTarget>
</PropertyGroup>
</Project> </Project>
\ No newline at end of file
...@@ -42,7 +42,7 @@ namespace ademco ...@@ -42,7 +42,7 @@ namespace ademco
// for crossplatform // for crossplatform
#ifndef __GNUG__ #ifndef __GNUG__
static inline int localtime_r(time_t* t, struct tm* tm_time) { inline int localtime_r(time_t* t, struct tm* tm_time) {
return localtime_s(tm_time, t); return localtime_s(tm_time, t);
} }
...@@ -58,7 +58,7 @@ namespace detail ...@@ -58,7 +58,7 @@ namespace detail
* @param crc 初始crc值 * @param crc 初始crc值
* @return crc16 * @return crc16
*/ */
static unsigned short CalculateCRC_char(char c, unsigned short crc) inline unsigned short CalculateCRC_char(char c, unsigned short crc)
{ {
static constexpr unsigned short crcTable[] = { static constexpr unsigned short crcTable[] = {
/* DEFINE THE FIRST ORDER POLYINOMIAL TABLE */ /* DEFINE THE FIRST ORDER POLYINOMIAL TABLE */
...@@ -109,7 +109,7 @@ static unsigned short CalculateCRC_char(char c, unsigned short crc) ...@@ -109,7 +109,7 @@ static unsigned short CalculateCRC_char(char c, unsigned short crc)
* @param crc 初始crc值 * @param crc 初始crc值
* @return crc16 * @return crc16
*/ */
static unsigned short CalculateCRC(const char* buff, size_t len, unsigned short crc = 0) inline unsigned short CalculateCRC(const char* buff, size_t len, unsigned short crc = 0)
{ {
unsigned short CRC = crc; unsigned short CRC = crc;
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
...@@ -125,7 +125,7 @@ static unsigned short CalculateCRC(const char* buff, size_t len, unsigned short ...@@ -125,7 +125,7 @@ static unsigned short CalculateCRC(const char* buff, size_t len, unsigned short
* @param crc 初始crc值 * @param crc 初始crc值
* @return crc16 * @return crc16
*/ */
static unsigned short CalculateCRC(const std::vector<char>& a, unsigned short crc) inline unsigned short CalculateCRC(const std::vector<char>& a, unsigned short crc)
{ {
unsigned short CRC = crc; unsigned short CRC = crc;
for (auto c : a) { for (auto c : a) {
...@@ -140,7 +140,7 @@ static unsigned short CalculateCRC(const std::vector<char>& a, unsigned short cr ...@@ -140,7 +140,7 @@ static unsigned short CalculateCRC(const std::vector<char>& a, unsigned short cr
* @return 字节表示的十进制数字 * @return 字节表示的十进制数字
* @note 示例:'f' 返回十进制数字15 * @note 示例:'f' 返回十进制数字15
*/ */
static char HexChar2Dec(char hex) inline char HexChar2Dec(char hex)
{ {
if (hex >= '0' && hex <= '9') if (hex >= '0' && hex <= '9')
return static_cast<char>(hex - '0'); return static_cast<char>(hex - '0');
...@@ -165,7 +165,7 @@ static char HexChar2Dec(char hex) ...@@ -165,7 +165,7 @@ static char HexChar2Dec(char hex)
* @note 示例: 字符串"FF"返回十进制数字255 * @note 示例: 字符串"FF"返回十进制数字255
* @note 仅用于安定宝数据包内的16进制字符串解析,长度较小,返回的十进制数字不能超过size_t范围 * @note 仅用于安定宝数据包内的16进制字符串解析,长度较小,返回的十进制数字不能超过size_t范围
*/ */
static size_t HexCharArrayToDec(const char* hex, size_t len) inline size_t HexCharArrayToDec(const char* hex, size_t len)
{ {
size_t dec = 0; size_t dec = 0;
for (size_t i = 0; i < len; i++) { for (size_t i = 0; i < len; i++) {
...@@ -182,7 +182,7 @@ static size_t HexCharArrayToDec(const char* hex, size_t len) ...@@ -182,7 +182,7 @@ static size_t HexCharArrayToDec(const char* hex, size_t len)
* @note 示例: 字符串"99"返回十进制数字99 * @note 示例: 字符串"99"返回十进制数字99
* @note 仅用于安定宝数据包内的16进制字符串解析,长度较小,返回的十进制数字不能超过size_t范围 * @note 仅用于安定宝数据包内的16进制字符串解析,长度较小,返回的十进制数字不能超过size_t范围
*/ */
static size_t NumCharArray2Dec(const char* str, size_t str_len) inline size_t NumCharArray2Dec(const char* str, size_t str_len)
{ {
size_t dec = 0; size_t dec = 0;
for (size_t i = 0; i < str_len; i++) { for (size_t i = 0; i < str_len; i++) {
...@@ -197,7 +197,7 @@ static size_t NumCharArray2Dec(const char* str, size_t str_len) ...@@ -197,7 +197,7 @@ static size_t NumCharArray2Dec(const char* str, size_t str_len)
* @return 十六进制字节,大写 * @return 十六进制字节,大写
* @note 示例: 数字10 返回字节 'A' * @note 示例: 数字10 返回字节 'A'
*/ */
static char Dec2Hex(char d) inline char Dec2Hex(char d)
{ {
if (0 <= d && d <= 9) { if (0 <= d && d <= 9) {
return static_cast<char>((unsigned char)d + (unsigned char)'0'); return static_cast<char>((unsigned char)d + (unsigned char)'0');
...@@ -218,7 +218,7 @@ static char Dec2Hex(char d) ...@@ -218,7 +218,7 @@ static char Dec2Hex(char d)
* @mask 掩码 扫描到掩码后立即停止 * @mask 掩码 扫描到掩码后立即停止
* @note 示例:输入数组:0x18 0x24 0x08 0x88 0x10 0x1f,以0x0F为掩码,输出字符串"18240888101" * @note 示例:输入数组:0x18 0x24 0x08 0x88 0x10 0x1f,以0x0F为掩码,输出字符串"18240888101"
*/ */
static const char* HexCharArrayToStr(char* dst, const char* hex, size_t len, unsigned char mask = (unsigned char)0x0F) inline const char* HexCharArrayToStr(char* dst, const char* hex, size_t len, unsigned char mask = (unsigned char)0x0F)
{ {
//AUTO_LOG_FUNCTION; //AUTO_LOG_FUNCTION;
//jlib::dump_hex(hex, len, spdlog::level::debug); //jlib::dump_hex(hex, len, spdlog::level::debug);
...@@ -249,7 +249,7 @@ static const char* HexCharArrayToStr(char* dst, const char* hex, size_t len, uns ...@@ -249,7 +249,7 @@ static const char* HexCharArrayToStr(char* dst, const char* hex, size_t len, uns
* @param bMax0FFF 输入的数字是否有最大值 0x0FFF * @param bMax0FFF 输入的数字是否有最大值 0x0FFF
* @note 示例:输入 256, 其hex为 0x0100, 输出 "0100" * @note 示例:输入 256, 其hex为 0x0100, 输出 "0100"
*/ */
static void Dec2HexCharArray_4(size_t dec, char* hex, bool bMax0FFF = true) inline void Dec2HexCharArray_4(size_t dec, char* hex, bool bMax0FFF = true)
{ {
if (dec < 0) { if (dec < 0) {
JLOG_ERRO("Dec2HexCharArray_4: 0LLL can't be negative."); JLOG_ERRO("Dec2HexCharArray_4: 0LLL can't be negative.");
...@@ -275,7 +275,7 @@ static void Dec2HexCharArray_4(size_t dec, char* hex, bool bMax0FFF = true) ...@@ -275,7 +275,7 @@ static void Dec2HexCharArray_4(size_t dec, char* hex, bool bMax0FFF = true)
* @note 当字符串转换后长度若不足max_hex_len则补 0x0F * @note 当字符串转换后长度若不足max_hex_len则补 0x0F
* @note 示例:输入 "18240888101",max_hex_len为9,输出 0x18 0x24 0x08 0x88 0x10 0x1f 0xff 0xff 0xff * @note 示例:输入 "18240888101",max_hex_len为9,输出 0x18 0x24 0x08 0x88 0x10 0x1f 0xff 0xff 0xff
*/ */
static void NumStr2HexCharArray_N(const char* str, char* hexarr, size_t max_hex_len = 9) inline void NumStr2HexCharArray_N(const char* str, char* hexarr, size_t max_hex_len = 9)
{ {
//AUTO_LOG_FUNCTION; //AUTO_LOG_FUNCTION;
if (str == nullptr) { if (str == nullptr) {
...@@ -322,7 +322,7 @@ static void NumStr2HexCharArray_N(const char* str, char* hexarr, size_t max_hex_ ...@@ -322,7 +322,7 @@ static void NumStr2HexCharArray_N(const char* str, char* hexarr, size_t max_hex_
* @param len 字符串长度 * @param len 字符串长度
* @note 起因是钱工的GPRS模块无法传输hex,只能传输ascii字节 * @note 起因是钱工的GPRS模块无法传输hex,只能传输ascii字节
*/ */
static void ConvertHiLoAsciiToHexCharArray(char* dst, const char* src, size_t len) inline void ConvertHiLoAsciiToHexCharArray(char* dst, const char* src, size_t len)
{ {
for (size_t i = 0; i < len; i++) { for (size_t i = 0; i < len; i++) {
if (!isxdigit((int)(unsigned char)src[i])) { if (!isxdigit((int)(unsigned char)src[i])) {
...@@ -359,7 +359,7 @@ enum class ToStringOption ...@@ -359,7 +359,7 @@ enum class ToStringOption
* @param show_space_between_hex 在 hex 之间插入空格 * @param show_space_between_hex 在 hex 之间插入空格
* @return std::string * @return std::string
*/ */
static std::string toString(const char* data, size_t len, // 数据 inline std::string toString(const char* data, size_t len, // 数据
ToStringOption option = ToStringOption::TRY_IS_ALNUM_FIRST, // 选项 ToStringOption option = ToStringOption::TRY_IS_ALNUM_FIRST, // 选项
bool show_x_for_hex = true, // 为 hex 显示 \x bool show_x_for_hex = true, // 为 hex 显示 \x
bool show_space_between_hex = false) // 在 hex 之间插入空格 bool show_space_between_hex = false) // 在 hex 之间插入空格
...@@ -387,7 +387,7 @@ static std::string toString(const char* data, size_t len, // 数据 ...@@ -387,7 +387,7 @@ static std::string toString(const char* data, size_t len, // 数据
* @param show_space_between_hex 在 hex 之间插入空格 * @param show_space_between_hex 在 hex 之间插入空格
* @return std::string * @return std::string
*/ */
static std::string toString(const std::vector<char>& data, // 数据 inline std::string toString(const std::vector<char>& data, // 数据
ToStringOption option = ToStringOption::TRY_IS_ALNUM_FIRST, // 选项 ToStringOption option = ToStringOption::TRY_IS_ALNUM_FIRST, // 选项
bool show_x_for_hex = true, // 为 hex 显示 \x bool show_x_for_hex = true, // 为 hex 显示 \x
bool show_space_between_hex = false) // 在 hex 之间插入空格 bool show_space_between_hex = false) // 在 hex 之间插入空格
......
...@@ -417,7 +417,7 @@ inline const std::wstring ademcoEventToStringChinese(ADEMCO_EVENT ademco_event, ...@@ -417,7 +417,7 @@ inline const std::wstring ademcoEventToStringChinese(ADEMCO_EVENT ademco_event,
#endif #endif
//! 是否主机状态事件 //! 是否主机状态事件
static inline bool isMachineStatusEvent(ADEMCO_EVENT ademco_event) inline bool isMachineStatusEvent(ADEMCO_EVENT ademco_event)
{ {
return ademco_event == EVENT_ARM return ademco_event == EVENT_ARM
|| ademco_event == EVENT_HALFARM || ademco_event == EVENT_HALFARM
...@@ -426,7 +426,7 @@ static inline bool isMachineStatusEvent(ADEMCO_EVENT ademco_event) ...@@ -426,7 +426,7 @@ static inline bool isMachineStatusEvent(ADEMCO_EVENT ademco_event)
} }
//! 是否主机类型事件 //! 是否主机类型事件
static inline bool isMachineTypeEvent(ADEMCO_EVENT ademco_event) inline bool isMachineTypeEvent(ADEMCO_EVENT ademco_event)
{ {
return ademco_event == EVENT_I_AM_NET_MODULE return ademco_event == EVENT_I_AM_NET_MODULE
|| ademco_event == EVENT_I_AM_GPRS || ademco_event == EVENT_I_AM_GPRS
...@@ -442,7 +442,7 @@ static inline bool isMachineTypeEvent(ADEMCO_EVENT ademco_event) ...@@ -442,7 +442,7 @@ static inline bool isMachineTypeEvent(ADEMCO_EVENT ademco_event)
} }
//! 事件是否需要控制源 //! 事件是否需要控制源
static inline bool isEventNeedControlSource(ADEMCO_EVENT ademco_event) inline bool isEventNeedControlSource(ADEMCO_EVENT ademco_event)
{ {
return ademco_event == EVENT_ARM return ademco_event == EVENT_ARM
|| ademco_event == EVENT_HALFARM || ademco_event == EVENT_HALFARM
......
...@@ -385,7 +385,7 @@ inline bool operator==(const XDataPtr& lhs, const XDataPtr& rhs) ...@@ -385,7 +385,7 @@ inline bool operator==(const XDataPtr& lhs, const XDataPtr& rhs)
} }
//! 生成xdata //! 生成xdata
static XDataPtr makeXData(const std::vector<char>& payload, inline XDataPtr makeXData(const std::vector<char>& payload,
XData::LengthFormat lengthFormat = XData::LengthFormat::TWO_HEX, XData::LengthFormat lengthFormat = XData::LengthFormat::TWO_HEX,
XData::DataFormat dataFormat = XData::DataFormat::AS_IS) XData::DataFormat dataFormat = XData::DataFormat::AS_IS)
{ {
...@@ -426,7 +426,7 @@ static XDataPtr makeXData(const std::vector<char>& payload, ...@@ -426,7 +426,7 @@ static XDataPtr makeXData(const std::vector<char>& payload,
return xdata; return xdata;
} }
static XDataPtr makeXData(const char* pack, size_t len, inline XDataPtr makeXData(const char* pack, size_t len,
XData::LengthFormat lengthFormat = XData::LengthFormat::TWO_HEX, XData::LengthFormat lengthFormat = XData::LengthFormat::TWO_HEX,
XData::DataFormat dataFormat = XData::DataFormat::AS_IS) { XData::DataFormat dataFormat = XData::DataFormat::AS_IS) {
if (len == 0) { return nullptr; } if (len == 0) { return nullptr; }
...@@ -434,7 +434,7 @@ static XDataPtr makeXData(const char* pack, size_t len, ...@@ -434,7 +434,7 @@ static XDataPtr makeXData(const char* pack, size_t len,
return makeXData(data, lengthFormat, dataFormat); return makeXData(data, lengthFormat, dataFormat);
} }
static XDataPtr makeXData(const unsigned char* pack, size_t len, inline XDataPtr makeXData(const unsigned char* pack, size_t len,
XData::LengthFormat lengthFormat = XData::LengthFormat::TWO_HEX, XData::LengthFormat lengthFormat = XData::LengthFormat::TWO_HEX,
XData::DataFormat dataFormat = XData::DataFormat::AS_IS) { XData::DataFormat dataFormat = XData::DataFormat::AS_IS) {
if (len == 0) { return nullptr; } if (len == 0) { return nullptr; }
...@@ -442,7 +442,7 @@ static XDataPtr makeXData(const unsigned char* pack, size_t len, ...@@ -442,7 +442,7 @@ static XDataPtr makeXData(const unsigned char* pack, size_t len,
return makeXData(data, lengthFormat, dataFormat); return makeXData(data, lengthFormat, dataFormat);
} }
static XDataPtr parseXData(const char* pack, const char* pack_end) inline XDataPtr parseXData(const char* pack, const char* pack_end)
{ {
XDataPtr xdata; XDataPtr xdata;
...@@ -488,7 +488,7 @@ static XDataPtr parseXData(const char* pack, const char* pack_end) ...@@ -488,7 +488,7 @@ static XDataPtr parseXData(const char* pack, const char* pack_end)
return xdata; return xdata;
} // parseXData } // parseXData
static std::string xdataToString(const XDataPtr& xdata, detail::ToStringOption option = detail::ToStringOption::TRY_IS_ALNUM_FIRST) { inline std::string xdataToString(const XDataPtr& xdata, detail::ToStringOption option = detail::ToStringOption::TRY_IS_ALNUM_FIRST) {
std::string str; std::string str;
if (!xdata) { return str; } if (!xdata) { return str; }
......
...@@ -65,7 +65,7 @@ enum class MachineStatus : Char { ...@@ -65,7 +65,7 @@ enum class MachineStatus : Char {
InvalidMachineStatus = 0xFF, InvalidMachineStatus = 0xFF,
}; };
static MachineStatus machineStatusFromChar(Char s) { inline MachineStatus machineStatusFromChar(Char s) {
if (static_cast<Char>(MachineStatus::Arm) <= s if (static_cast<Char>(MachineStatus::Arm) <= s
&& s < static_cast<Char>(MachineStatus::MachineStatusCount)) && s < static_cast<Char>(MachineStatus::MachineStatusCount))
{ {
...@@ -75,7 +75,7 @@ static MachineStatus machineStatusFromChar(Char s) { ...@@ -75,7 +75,7 @@ static MachineStatus machineStatusFromChar(Char s) {
} }
#ifdef ENABLE_COMMON_MACHINE_STATUS_TO_STRING #ifdef ENABLE_COMMON_MACHINE_STATUS_TO_STRING
static const char* machineStatusToString(MachineStatus status) { inline const char* machineStatusToString(MachineStatus status) {
switch (status) { switch (status) {
case MachineStatus::Arm: return "Arm"; case MachineStatus::Arm: return "Arm";
case MachineStatus::HalfArm:return "HalfArm"; case MachineStatus::HalfArm:return "HalfArm";
...@@ -85,7 +85,7 @@ static const char* machineStatusToString(MachineStatus status) { ...@@ -85,7 +85,7 @@ static const char* machineStatusToString(MachineStatus status) {
} }
} }
static const wchar_t* machineStatusToWString(MachineStatus status) { inline const wchar_t* machineStatusToWString(MachineStatus status) {
switch (status) { switch (status) {
case MachineStatus::Arm: return L"布防"; case MachineStatus::Arm: return L"布防";
case MachineStatus::HalfArm:return L"半布防"; case MachineStatus::HalfArm:return L"半布防";
...@@ -127,7 +127,7 @@ enum MachineType : Char { ...@@ -127,7 +127,7 @@ enum MachineType : Char {
InvalidMachineType = 0xFF, InvalidMachineType = 0xFF,
}; };
static MachineType machineTypeFromChar(Char t) { inline MachineType machineTypeFromChar(Char t) {
if (static_cast<Char>(MachineType::WiFi) <= t if (static_cast<Char>(MachineType::WiFi) <= t
&& t < static_cast<Char>(MachineType::MachineTypeCount)) && t < static_cast<Char>(MachineType::MachineTypeCount))
{ {
...@@ -152,7 +152,7 @@ static constexpr MachineType AllMachineTypes[MachineTypeCount] = { ...@@ -152,7 +152,7 @@ static constexpr MachineType AllMachineTypes[MachineTypeCount] = {
}; };
//! 最大防区号根据型号不同而不同 //! 最大防区号根据型号不同而不同
static uint16_t zoneMax(MachineType type) { inline uint16_t zoneMax(MachineType type) {
switch (type) { switch (type) {
case MachineType::Gprs_IoT: case MachineType::Gprs_IoT:
case MachineType::Gprs: case MachineType::Gprs:
...@@ -185,17 +185,17 @@ static uint16_t zoneMax(MachineType type) { ...@@ -185,17 +185,17 @@ static uint16_t zoneMax(MachineType type) {
} }
//! 防区号是否合法(可以包含0防区) //! 防区号是否合法(可以包含0防区)
static bool isValidZone(MachineType type, uint16_t zone) { inline bool isValidZone(MachineType type, uint16_t zone) {
return ademco::Zone4MachineSelf <= zone && zone <= zoneMax(type); return ademco::Zone4MachineSelf <= zone && zone <= zoneMax(type);
} }
//! 防区号是否合法(不可以可以包含0防区) //! 防区号是否合法(不可以可以包含0防区)
static bool isValidZoneStrict(MachineType type, uint16_t zone) { inline bool isValidZoneStrict(MachineType type, uint16_t zone) {
return ademco::ZoneMin <= zone && zone <= zoneMax(type); return ademco::ZoneMin <= zone && zone <= zoneMax(type);
} }
//! 主机是否已投产使用 //! 主机是否已投产使用
static bool machineIsSelling(MachineType type) { inline bool machineIsSelling(MachineType type) {
return type == MachineType::NetMod return type == MachineType::NetMod
|| type == MachineType::Gprs || type == MachineType::Gprs
|| type == MachineType::Gprs_IoT || type == MachineType::Gprs_IoT
...@@ -210,29 +210,29 @@ static bool machineIsSelling(MachineType type) { ...@@ -210,29 +210,29 @@ static bool machineIsSelling(MachineType type) {
} }
//! 主机是否具有布防功能 //! 主机是否具有布防功能
static bool machineCanArm(MachineType type) { inline bool machineCanArm(MachineType type) {
return machineIsSelling(type) && (type != MachineType::Nb); return machineIsSelling(type) && (type != MachineType::Nb);
} }
//! 主机是否具有撤防功能 //! 主机是否具有撤防功能
static bool machineCanDisarm(MachineType type) { inline bool machineCanDisarm(MachineType type) {
return machineIsSelling(type) && (type != MachineType::Nb); return machineIsSelling(type) && (type != MachineType::Nb);
} }
//! 主机是否可以进入设置状态 //! 主机是否可以进入设置状态
static bool machineCanEnterSettings(MachineType type) { inline bool machineCanEnterSettings(MachineType type) {
return machineIsSelling(type); return machineIsSelling(type);
} }
//! 主机是否具有半布防功能 //! 主机是否具有半布防功能
static bool machineCanHalfArm(MachineType type) { inline bool machineCanHalfArm(MachineType type) {
return type == MachineType::NetMod return type == MachineType::NetMod
|| type == MachineType::Lcd || type == MachineType::Lcd
; ;
} }
//! 主机是否可以报告信号强度 //! 主机是否可以报告信号强度
static bool machineCanReportSignalStrength(MachineType type) { inline bool machineCanReportSignalStrength(MachineType type) {
return type == MachineType::Gprs return type == MachineType::Gprs
|| type == MachineType::Gprs_IoT || type == MachineType::Gprs_IoT
|| type == MachineType::IoT || type == MachineType::IoT
...@@ -245,7 +245,7 @@ static bool machineCanReportSignalStrength(MachineType type) { ...@@ -245,7 +245,7 @@ static bool machineCanReportSignalStrength(MachineType type) {
} }
//! 主机本身是否可以短信报警(不算通过服务如阿里语音等) //! 主机本身是否可以短信报警(不算通过服务如阿里语音等)
static bool machineCanReportBySMS(MachineType type) { inline bool machineCanReportBySMS(MachineType type) {
return type == MachineType::Gprs return type == MachineType::Gprs
|| type == MachineType::Lcd || type == MachineType::Lcd
|| type == MachineType::TrueColor || type == MachineType::TrueColor
...@@ -256,14 +256,14 @@ static bool machineCanReportBySMS(MachineType type) { ...@@ -256,14 +256,14 @@ static bool machineCanReportBySMS(MachineType type) {
} }
//! 主机是否支持有线防区 //! 主机是否支持有线防区
static bool machineHasWiredZone(MachineType type) { inline bool machineHasWiredZone(MachineType type) {
return type == MachineType::NetMod return type == MachineType::NetMod
|| type == MachineType::TrueColor || type == MachineType::TrueColor
|| type == MachineType::ThreeSection; || type == MachineType::ThreeSection;
} }
//! 主机最小有线防区号 //! 主机最小有线防区号
static ademco::AdemcoZone wiredZoneMin(MachineType type) { inline ademco::AdemcoZone wiredZoneMin(MachineType type) {
switch (type) { switch (type) {
case hb::common::NetMod: return 1; case hb::common::NetMod: return 1;
...@@ -294,7 +294,7 @@ static ademco::AdemcoZone wiredZoneMin(MachineType type) { ...@@ -294,7 +294,7 @@ static ademco::AdemcoZone wiredZoneMin(MachineType type) {
} }
//! 主机最大有线防区号 //! 主机最大有线防区号
static ademco::AdemcoZone wiredZoneMax(MachineType type) { inline ademco::AdemcoZone wiredZoneMax(MachineType type) {
switch (type) { switch (type) {
case hb::common::Gprs_IoT: case hb::common::Gprs_IoT:
break; break;
...@@ -326,17 +326,17 @@ static ademco::AdemcoZone wiredZoneMax(MachineType type) { ...@@ -326,17 +326,17 @@ static ademco::AdemcoZone wiredZoneMax(MachineType type) {
} }
//! 主机是否可以直接写入防区数据(无需对码) //! 主机是否可以直接写入防区数据(无需对码)
static bool machineCanDirectlyWriteZone(MachineType type) { inline bool machineCanDirectlyWriteZone(MachineType type) {
return type == MachineType::NetMod; return type == MachineType::NetMod;
} }
//! 主机是否可以挂载分机 //! 主机是否可以挂载分机
static bool machineCanLinkSubMachine(MachineType type) { inline bool machineCanLinkSubMachine(MachineType type) {
return type == MachineType::NetMod; return type == MachineType::NetMod;
} }
#ifdef ENABLE_COMMON_MACHINE_TYPE_TO_STRING #ifdef ENABLE_COMMON_MACHINE_TYPE_TO_STRING
static const char* machineTypeToString(MachineType type) { inline const char* machineTypeToString(MachineType type) {
switch (type) { switch (type) {
case MachineType::WiFi: return "0 WiFi"; case MachineType::WiFi: return "0 WiFi";
case MachineType::Camera: return "1 Camera"; case MachineType::Camera: return "1 Camera";
...@@ -354,7 +354,7 @@ static const char* machineTypeToString(MachineType type) { ...@@ -354,7 +354,7 @@ static const char* machineTypeToString(MachineType type) {
} }
} }
static const wchar_t* machineTypeToWString(MachineType type) { inline const wchar_t* machineTypeToWString(MachineType type) {
switch (type) { switch (type) {
case MachineType::WiFi: return L"0 WiFi主机"; case MachineType::WiFi: return L"0 WiFi主机";
case MachineType::Camera: return L"1 摄像头主机"; case MachineType::Camera: return L"1 摄像头主机";
...@@ -415,7 +415,7 @@ enum ZoneProperty : Char { ...@@ -415,7 +415,7 @@ enum ZoneProperty : Char {
InvalidZoneProperty = 0xFF, InvalidZoneProperty = 0xFF,
}; };
static ZoneProperty zonePropertyFromChar(Char zp) { inline ZoneProperty zonePropertyFromChar(Char zp) {
if (ZoneProperty::Buglar <= zp && zp < ZoneProperty::ZonePropertyCount) if (ZoneProperty::Buglar <= zp && zp < ZoneProperty::ZonePropertyCount)
{ return static_cast<ZoneProperty>(zp); } { return static_cast<ZoneProperty>(zp); }
return ZoneProperty::InvalidZoneProperty; return ZoneProperty::InvalidZoneProperty;
...@@ -423,7 +423,7 @@ static ZoneProperty zonePropertyFromChar(Char zp) { ...@@ -423,7 +423,7 @@ static ZoneProperty zonePropertyFromChar(Char zp) {
//! 根据防区属性判断是否支持失联报告 //! 根据防区属性判断是否支持失联报告
//! 失联报告是主机侧实现的跟防区属性没关系,但是人为限制了只有以下属性的才可以设置 //! 失联报告是主机侧实现的跟防区属性没关系,但是人为限制了只有以下属性的才可以设置
static bool zonePropCanReportLost(ZoneProperty zp) { inline bool zonePropCanReportLost(ZoneProperty zp) {
switch (zp) { switch (zp) {
case hb::common::Buglar: case hb::common::Buglar:
case hb::common::Emergency: case hb::common::Emergency:
...@@ -437,11 +437,11 @@ static bool zonePropCanReportLost(ZoneProperty zp) { ...@@ -437,11 +437,11 @@ static bool zonePropCanReportLost(ZoneProperty zp) {
} }
} }
static std::vector<ZoneProperty> getAvailableZoneProperties() { inline std::vector<ZoneProperty> getAvailableZoneProperties() {
return { Buglar, Emergency, Fire, Duress, Gas, Water, SubMachine, RemoteControl, BuglarHalf, Shield, DoorRing, Bypass }; return { Buglar, Emergency, Fire, Duress, Gas, Water, SubMachine, RemoteControl, BuglarHalf, Shield, DoorRing, Bypass };
} }
static std::vector<ZoneProperty> getAvailableZoneProperties(MachineType type) { inline std::vector<ZoneProperty> getAvailableZoneProperties(MachineType type) {
switch (type) { switch (type) {
case hb::common::WiFi: case hb::common::WiFi:
break; break;
...@@ -471,7 +471,7 @@ static std::vector<ZoneProperty> getAvailableZoneProperties(MachineType type) { ...@@ -471,7 +471,7 @@ static std::vector<ZoneProperty> getAvailableZoneProperties(MachineType type) {
} }
#ifdef ENABLE_COMMON_ZONE_PROPERTY_TO_STRING #ifdef ENABLE_COMMON_ZONE_PROPERTY_TO_STRING
static const wchar_t* zonePropertyToStringChinese(ZoneProperty zp) { inline const wchar_t* zonePropertyToStringChinese(ZoneProperty zp) {
switch (zp) { switch (zp) {
case ZoneProperty::Buglar: return L"匪警全局"; case ZoneProperty::Buglar: return L"匪警全局";
case ZoneProperty::Emergency: return L"匪警紧急"; case ZoneProperty::Emergency: return L"匪警紧急";
...@@ -493,7 +493,8 @@ static const wchar_t* zonePropertyToStringChinese(ZoneProperty zp) { ...@@ -493,7 +493,8 @@ static const wchar_t* zonePropertyToStringChinese(ZoneProperty zp) {
default: return L"无效属性"; default: return L"无效属性";
} }
} }
static const char* zonePropertyToStringEn(ZoneProperty zp) {
inline const char* zonePropertyToStringEn(ZoneProperty zp) {
switch (zp) { switch (zp) {
case ZoneProperty::Buglar: return "Buglar"; case ZoneProperty::Buglar: return "Buglar";
case ZoneProperty::Emergency: return "Emergency"; case ZoneProperty::Emergency: return "Emergency";
...@@ -784,7 +785,7 @@ union MachineTimer { ...@@ -784,7 +785,7 @@ union MachineTimer {
MachineTimer() { memset(data, 0xFF, 8); } MachineTimer() { memset(data, 0xFF, 8); }
}; };
static_assert(sizeof(MachineTimer) == 8, "sizeof(MachineTimer) must be 8"); static_assert(sizeof(MachineTimer) == 8, "sizeof(MachineTimer) must be 8");
static inline bool isValidMachineTimer(const Timer& t) { inline bool isValidMachineTimer(const Timer& t) {
return 0 <= t.armAt.hour && t.armAt.hour < 24 && return 0 <= t.armAt.hour && t.armAt.hour < 24 &&
0 <= t.armAt.minute && t.armAt.minute < 60 && 0 <= t.armAt.minute && t.armAt.minute < 60 &&
0 <= t.disarmAt.hour && t.disarmAt.hour < 24 && 0 <= t.disarmAt.hour && t.disarmAt.hour < 24 &&
...@@ -1248,20 +1249,20 @@ enum Key : Char { ...@@ -1248,20 +1249,20 @@ enum Key : Char {
typedef std::vector<Key> Keys; typedef std::vector<Key> Keys;
//! 用于将Key的值Char转为Key,不特殊处理Key_0 //! 用于将Key的值Char转为Key,不特殊处理Key_0
static Key keyFromChar(Char c) { inline Key keyFromChar(Char c) {
if ((Key_1 <= c && c <= Key_STOP_SOUND) || (c == Key_STOP_ALARM)) { if ((Key_1 <= c && c <= Key_STOP_SOUND) || (c == Key_STOP_ALARM)) {
return static_cast<Key>(c); return static_cast<Key>(c);
}return Key_NULL; }return Key_NULL;
} }
//! 将 0~9转换为Key,特殊处理Key_0 //! 将 0~9转换为Key,特殊处理Key_0
static Key keyFromNumber(int i) { inline Key keyFromNumber(int i) {
if (i == 0) { return Key_0; } if (i == 0) { return Key_0; }
else if (1 <= i && i <= 9) { return static_cast<Key>(i); } else if (1 <= i && i <= 9) { return static_cast<Key>(i); }
else { return Key_NULL; } else { return Key_NULL; }
} }
static char keyToPrintableChar(Key key) { inline char keyToPrintableChar(Key key) {
switch (key) { switch (key) {
case Key_1: case Key_2: case Key_3: case Key_1: case Key_2: case Key_3:
case Key_4: case Key_5: case Key_4: case Key_5:
...@@ -1816,7 +1817,7 @@ enum ZoneType : Char { ...@@ -1816,7 +1817,7 @@ enum ZoneType : Char {
ZT_INVALID = 0xFF, ZT_INVALID = 0xFF,
}; };
static ZoneType zoneTypeFromChar(Char c) { inline ZoneType zoneTypeFromChar(Char c) {
switch (c) { switch (c) {
case ZT_ZONE: return ZT_ZONE; case ZT_ZONE: return ZT_ZONE;
case ZT_SUBMACHINE: return ZT_SUBMACHINE; case ZT_SUBMACHINE: return ZT_SUBMACHINE;
...@@ -1850,7 +1851,7 @@ enum ZoneProperty : Char { ...@@ -1850,7 +1851,7 @@ enum ZoneProperty : Char {
ZP_INVALID = 0xFF, ZP_INVALID = 0xFF,
}; };
static ZoneProperty zonePropertyFromChar(Char c) { inline ZoneProperty zonePropertyFromChar(Char c) {
switch (c) { switch (c) {
case ZP_GLOBAL: return ZP_GLOBAL; case ZP_GLOBAL: return ZP_GLOBAL;
case ZP_HALF: return ZP_HALF; case ZP_HALF: return ZP_HALF;
...@@ -1866,7 +1867,7 @@ static ZoneProperty zonePropertyFromChar(Char c) { ...@@ -1866,7 +1867,7 @@ static ZoneProperty zonePropertyFromChar(Char c) {
} }
#ifdef ENABLE_OLD_ZONE_PROPERTY_TO_STRING #ifdef ENABLE_OLD_ZONE_PROPERTY_TO_STRING
static const wchar_t* zonePropertyToString(ZoneProperty zp) { inline const wchar_t* zonePropertyToString(ZoneProperty zp) {
switch (zp) { switch (zp) {
case ZP_GLOBAL: return L"全局盗警"; case ZP_GLOBAL: return L"全局盗警";
case ZP_HALF: return L"半局盗警"; case ZP_HALF: return L"半局盗警";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment