//
|
// Defines.h
|
// airtree
|
//
|
// Created by WindShan on 2016/11/10.
|
// Copyright © 2016年 Gloria. All rights reserved.
|
//
|
|
|
#if (DEBUG || TESTCASE)
|
#define LOG_INFO(format, ...) NSLog(format, ## __VA_ARGS__)
|
#else
|
#define LOG_INFO(format, ...)
|
#endif
|
|
// 日志输出宏
|
#define BASE_LOG(cls,sel) LOG_INFO(@"%@-%@",NSStringFromClass(cls), NSStringFromSelector(sel))
|
#define BASE_ERROR_LOG(cls,sel,error) LOG_INFO(@"ERROR:%@-%@-%@",NSStringFromClass(cls), NSStringFromSelector(sel), error)
|
#define BASE_INFO_LOG(cls,sel,info) LOG_INFO(@"INFO:%@-%@-%@",NSStringFromClass(cls), NSStringFromSelector(sel), info)
|
|
// 日志输出函数
|
#if (DEBUG || TESTCASE)
|
#define BASE_LOG_FUN() BASE_LOG([self class], _cmd)
|
#define BASE_ERROR_FUN(error) BASE_ERROR_LOG([self class],_cmd,error)
|
#define BASE_INFO_FUN(info) BASE_INFO_LOG([self class],_cmd,info)
|
#else
|
#define BASE_LOG_FUN()
|
#define BASE_ERROR_FUN(error)
|
#define BASE_INFO_FUN(info)
|
#endif
|
|
// 设备类型判断
|
#define IsiPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
|
#define IsiPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
|
#define IsRetain ([[UIScreen mainScreen] scale] >= 2.0)
|
#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
|
#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
|
#define kScreenBounds [UIScreen mainScreen].bounds
|
|
|
#define ScreenMaxLength (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
|
#define ScreenMinLength (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
|
|
#define IsiPhone4 (IsiPhone && ScreenMaxLength < 568.0)
|
#define IsiPhone5 (IsiPhone && ScreenMaxLength == 568.0)
|
#define IsiPhone6 (IsiPhone && ScreenMaxLength == 667.0)
|
#define IsiPhone6P (IsiPhone && ScreenMaxLength == 736.0)
|
|
// iOS系统版本
|
#define IOSBaseVersion11 11.0
|
#define IOSBaseVersion10 10.0
|
#define IOSBaseVersion9 9.0
|
#define IOSBaseVersion8 8.0
|
#define IOSBaseVersion7 7.0
|
#define IOSBaseVersion6 6.0
|
|
|
// 过去当前APP版本号
|
#define XcodeAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
|
|
// 消息通知
|
#define RegisterNotify(_name, _selector) \
|
[[NSNotificationCenter defaultCenter] addObserver:self \
|
selector:_selector name:_name object:nil];
|
|
#define RemoveNofify \
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
#define SendNotify(_name, _object) \
|
[[NSNotificationCenter defaultCenter] postNotificationName:_name object:_object];
|
|
// 消息通知Key
|
#define NotifyDevideInfo @"MonitorDevice"
|
|
|
// 设置颜色值
|
#define RgbColor(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
|
#define RGBA(r, g, b, a) ([UIColor colorWithRed:(r / 255.0) green:(g / 255.0) blue:(b / 255.0) alpha:a])
|
|
#define BGCOLOR [UIColor colorWithRed:241/255.0 green:241/255.0 blue:241/255.0 alpha:1]
|
#define kUIColorFromRGB(rgbValue) [UIColor \
|
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
|
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
|
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
|
#define NAVIGATIONTINTCOLOR kUIColorFromRGB(0x23c35c)
|
#define BLACKTEXTCOLOR_TITLE kUIColorFromRGB(0x303030)
|
#define BLACKTEXTCOLOR_SUB kUIColorFromRGB(0x7b7b7b)
|
#define BLUE_BUTTON_COLOR RgbColor(85, 81, 168)
|
|
|
// 字体定义
|
#define FONT8 [UIFont systemFontOfSize:8.0]
|
#define FONT10 [UIFont systemFontOfSize:10.0]
|
#define FONT11 [UIFont systemFontOfSize:11.0]
|
#define FONT12 [UIFont systemFontOfSize:12.0]
|
#define FONT13 [UIFont systemFontOfSize:13.0]
|
#define FONT14 [UIFont systemFontOfSize:14.0]
|
#define FONT15 [UIFont systemFontOfSize:15.0]
|
#define FONT16 [UIFont systemFontOfSize:16.0]
|
#define FONT17 [UIFont systemFontOfSize:17.0]
|
#define FONT18 [UIFont systemFontOfSize:18.0]
|
|
// 其他常量
|
#define NavBarHeight 44
|
#define NavBarHeight7 64
|
/*! Status bar height. */
|
#define BA_StatusBarHeight 20.f
|
|
/*! Navigation bar height. */
|
#define BA_NavigationBarHeight 44.f
|
|
/*! Tabbar height. self.tabBarController.tabBar.height */
|
#define BA_TabbarHeight 49.f
|
|
/*! Status bar & navigation bar height. */
|
#define BA_StatusBarAndNavigationBarHeight (20.f + 44.f)
|
|
#define UserDefault [NSUserDefaults standardUserDefaults]
|
#define Application [UIApplication sharedApplication]
|
#define GetAppDelegate [AppDelegate AppInstance]
|
|
// 弱引用和强引用转换
|
//弱引用/强引用 可配对引用在外面用MPWeakSelf(self),block用MPStrongSelf(self) 也可以单独引用在外面用MPWeakSelf(self) block里面用weakself
|
#define MPWeakSelf(type) __weak typeof(type) weak##type = type;
|
#define MPStrongSelf(type) __strong typeof(type) type = weak##type;
|
|
/*! weakSelf */
|
#define BA_WEAKSELF typeof(self) __weak weakSelf = self
|
|
//不同屏幕尺寸字体适配(320,568是因为效果图为IPHONE5 如果不是则根据实际情况修改)
|
#define kScreenWidthRatio (SCREEN_WIDTH / 320.0)
|
#define kScreenHeightRatio (SCREEN_HEIGHT / 568.0)
|
#define AdaptedWidth(x) ceilf((x) * kScreenWidthRatio)
|
#define AdaptedHeight(x) ceilf((x) * kScreenHeightRatio)
|
#define AdaptedFontSize(R) CHINESE_SYSTEM(AdaptedWidth(R))
|
|
/*! 用safari打开URL */
|
#define BA_OpenUrl(urlStr) [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]]
|
|
/*! 复制文字内容 */
|
#define BA_CopyContent(content) [[UIPasteboard generalPasteboard] setString:content]
|
/*! 图片 */
|
#define BA_ImageName(imageName) [UIImage imageNamed:imageName]
|
|
/*! 字体 */
|
#define BA_FontSize(fontSize) [UIFont systemFontOfSize:fontSize]
|
|
//中文字体
|
#define CHINESE_FONT_NAME @"Heiti SC"
|
#define CHINESE_SYSTEM(x) [UIFont fontWithName:CHINESE_FONT_NAME size:x]
|
|
//上传图片相关
|
#define kImageCollectionCell_Width floorf((SCREEN_WIDTH - 10*2- 10*3)/3)
|
//最大的上传图片张数
|
#define kupdateMaximumNumberOfImage 12
|
|
//是否启动 libsmartlinklib_7x.a
|
#define USE_SmartLink 101
|
|
// socket 连接路径 0 测试环境 1 正式环境
|
#define ProductType 0
|
|
/*网络相关
|
{result:ok, data:data}
|
{result:error,message:""}
|
{result:invalidatetoken, message:"token失效"}
|
*/
|
#define NetOk @"ok"
|
#define NetData @"data"
|
#define HTTPGET @"GET"
|
#define HTTPPOST @"POST"
|
#define INTERFACE_VERSION 1
|
|
// 提示信息
|
#define LoginingTip @"登录中..."
|
#define LoadingTip @"加载中..."
|
#define LoginCheckTip @"用户名或密码不能为空"
|
|
// 设备控制命令
|
#define DEVICE_CONTROL_COMMAND_OPEN 1 // 设备开关
|
#define DEVICE_CONTROL_COMMAND_WATER 2 // 1 注水 2 排水
|
#define DEVICE_CONTROL_COMMAND_AIR 3 // 空气净化开关 0 关闭 1 自动 2 静音 3 低 4 中 5 高
|
#define DEVICE_CONTROL_COMMAND_TEMPERATURE 4 // 水温大小控制
|
#define DEVICE_CONTROL_COMMAND_WATERLOOP 5 // 水循时间环控制
|
#define DEVICE_CONTROL_COMMAND_VENTILATION 6 // 楼层换气控制
|
#define DEVICE_CONTROL_COMMAND_LIGHT 7 // 楼层光照控制
|
#define DEVICE_CONTROL_COMMAND_WATERTIME 9 // 控制每次水循环时长
|
#define DEVICE_CONTROL_COMMAND_VENTILATIONTIME 10 // 控制每次换气时长
|
|
#define BLE_DEVICE_UUID @"0003CDD0-0000-1000-8000-00805F9B0131"
|
#define LISTON_DEVICE_UUID @"0003CDD1-0000-1000-8000-00805F9B0131" // 监听
|
#define WRITE_DEVICE_UUID @"0003CDD2-0000-1000-8000-00805F9B0131" // 发消息
|
|
// < 0.25安全
|
// >= 0.25 && < 0.8轻微
|
// >= 0.8 && < 2中度
|
// >= 2严重
|
|
#define FUSHE_MIN_VALUE 0
|
#define FUSHE_SAFE_VALUE 250 // 安全
|
#define FUSHE_SLIGHT_VALUE 800 // 轻微
|
#define FUSHE_MODERATE_VALUE 2000 // 中度
|
#define FUSHE_MAX_VALUE 4000 // 警告
|