DeviceConfigViewController.mm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. //
  2. // DeviceConfigViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by Levi on 2018/5/17.
  6. // Copyright © 2018年 Levi. All rights reserved.
  7. //
  8. #import "EncodeViewController.h" //编码配置
  9. #import "AlarmDetectViewController.h" //报警配置
  10. #import "RecordViewController.h" //录像配置
  11. #import "ParamViewController.h" //图像配置
  12. #import "TimeSynViewController.h" //时间同步
  13. #import "VideoFileViewController.h" //设备录像查询
  14. #import "PictureFileViewController.h"//设备图片查询
  15. #import "PasswordViewController.h" //密码修改
  16. #import "StorageViewController.h" //存储空间
  17. #import "AboutDeviceViewController.h" //关于设备信息
  18. #import "UpgradeDeviceViewController.h" //设备升级
  19. #import "DeviceconfigTableViewCell.h"
  20. #import "DeviceConfigViewController.h"
  21. #import "SystemInfoConfig.h"
  22. #import "DeviceManager.h"
  23. #import "CloudAbilityViewController.h"
  24. #import "AlarmMessageViewController.h" //推送消息
  25. #import "EncodingFormatViewController.h" //编码格式设置
  26. #import "AnalyzerViewController.h" //智能分析
  27. #import "SystemFunctionConfig.h"
  28. #import "WaterMarkViewController.h" //水印设置
  29. #import "BuzzerViewController.h" //蜂鸣功能
  30. #import "ShutDownTimeViewController.h" //设备休眠时间
  31. #import "HumanDetectionViewController.h" //人形检测
  32. #import "SensorlistVCViewController.h"
  33. @interface DeviceConfigViewController ()<UITableViewDelegate,UITableViewDataSource,SystemInfoConfigDelegate>
  34. @property (nonatomic, strong) UITableView *devConfigTableView;
  35. @property (nonatomic, strong) NSArray *configTitleArray;
  36. @property (nonatomic, strong) SystemInfoConfig * config;
  37. @property (nonatomic, strong) SystemFunctionConfig * functionConfig;
  38. @end
  39. @implementation DeviceConfigViewController
  40. - (UITableView *)devConfigTableView {
  41. if (!_devConfigTableView) {
  42. _devConfigTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight -64 ) style:UITableViewStylePlain];
  43. _devConfigTableView.delegate = self;
  44. _devConfigTableView.dataSource = self;
  45. _devConfigTableView.rowHeight = 60;
  46. [_devConfigTableView registerClass:[DeviceconfigTableViewCell class] forCellReuseIdentifier:@"cell"];
  47. }
  48. return _devConfigTableView;
  49. }
  50. #pragma mark -- viewDidLoad
  51. - (void)viewDidLoad {
  52. [super viewDidLoad];
  53. [[NSNotificationCenter defaultCenter] postNotificationName:MasterAccount object:@"123"];
  54. self.automaticallyAdjustsScrollViewInsets = NO;
  55. self.navigationController.navigationBar.translucent = NO;
  56. self.edgesForExtendedLayout = UIRectEdgeNone;
  57. //设置导航栏样式
  58. [self setNaviStyle];
  59. //初始化数据
  60. [self initDataSource];
  61. //配置子视图
  62. [self configSubView];
  63. //获取各个设备配置前,如果设备(门铃门锁等等)是在休眠状态,需要先进行唤醒
  64. [self checkDeviceSleepType];
  65. //获取设备能力级SystemFunction
  66. [self getSystemFunction];
  67. //获取设备信息systeminfo
  68. [self getSysteminfo];
  69. }
  70. //获取设备能力级SystemFunction
  71. - (void)getSystemFunction{
  72. if (!_functionConfig) {
  73. _functionConfig = [[SystemFunctionConfig alloc] init];
  74. }
  75. //获取通道
  76. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  77. [_functionConfig getSystemFunction:channel.deviceMac];
  78. }
  79. //编码配置需要知道设备的模拟通道数量,所以在编码配置前需要获取一下
  80. - (void)getSysteminfo {
  81. if (_config == nil) {
  82. _config = [[SystemInfoConfig alloc] init];
  83. _config.delegate = self;
  84. }
  85. [SVProgressHUD show];
  86. [_config getSystemInfo];
  87. }
  88. //休眠中的设备需要先唤醒才能去获取其他配置
  89. - (void)checkDeviceSleepType {
  90. ChannelObject *object = [[DeviceControl getInstance] getSelectChannel];
  91. [[DeviceManager getInstance] deviceWeakUp:object.deviceMac];
  92. }
  93. #pragma mark 获取设备systeminfo回调
  94. - (void)SystemInfoConfigGetResult:(NSInteger)result {
  95. if (result >0) {
  96. //获取成功
  97. [SVProgressHUD dismiss];
  98. }else{
  99. //获取失败
  100. [MessageUI ShowErrorInt:(int)result];
  101. }
  102. }
  103. #pragma mark -- UITableViewDelegate/DataSource
  104. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  105. return self.configTitleArray.count;
  106. }
  107. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  108. DeviceconfigTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  109. if (!cell) {
  110. cell = [[DeviceconfigTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  111. }
  112. NSString *detailInfo = [self.configTitleArray[indexPath.row] objectForKey:@"detailInfo"];
  113. if (detailInfo && detailInfo.length > 0) {
  114. cell.Labeltext.frame = CGRectMake(64, 9, ScreenWidth - 64, 22);
  115. cell.detailLabel.hidden = NO;
  116. cell.Labeltext.text = [self.configTitleArray[indexPath.row] objectForKey:@"title"];
  117. cell.detailLabel.text = detailInfo;
  118. }else{
  119. cell.Labeltext.frame = CGRectMake(64, 18, ScreenWidth - 64, 22);
  120. cell.detailLabel.hidden = YES;
  121. cell.Labeltext.text = [self.configTitleArray[indexPath.row] objectForKey:@"title"];
  122. }
  123. return cell;
  124. }
  125. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  126. NSString *titleStr = [self.configTitleArray[indexPath.row] objectForKey:@"title"];
  127. if ([titleStr isEqualToString:TS("alarm_config")]) {
  128. AlarmDetectViewController *alarmDetectVC = [[AlarmDetectViewController alloc] initWithNibName:nil bundle:nil];
  129. [self.navigationController pushViewController:alarmDetectVC animated:NO];
  130. }else if ([titleStr isEqualToString:TS("Encode_config")]){ //编码配置
  131. EncodeViewController *encodeVC = [[EncodeViewController alloc] initWithNibName:nil bundle:nil];
  132. [self.navigationController pushViewController:encodeVC animated:NO];
  133. }else if ([titleStr isEqualToString:TS("Record_config")]){ //录像配置
  134. RecordViewController *encodeVC = [[RecordViewController alloc] initWithNibName:nil bundle:nil];
  135. [self.navigationController pushViewController:encodeVC animated:NO];
  136. }else if ([titleStr isEqualToString:TS("picture_vonfig")]){ //图像配置
  137. ParamViewController *encodeVC = [[ParamViewController alloc] initWithNibName:nil bundle:nil];
  138. [self.navigationController pushViewController:encodeVC animated:NO];
  139. }else if ([titleStr isEqualToString:TS("time_syn")]){ //时间同步
  140. TimeSynViewController *timeVC = [[TimeSynViewController alloc] initWithNibName:nil bundle:nil];
  141. [self.navigationController pushViewController:timeVC animated:NO];
  142. }else if ([titleStr isEqualToString:TS("record_file")]){ //设备录像
  143. VideoFileViewController *videoVC = [[VideoFileViewController alloc] initWithNibName:nil bundle:nil];
  144. [self.navigationController pushViewController:videoVC animated:NO];
  145. }else if ([titleStr isEqualToString:TS("picture_file")]){ //设备图片
  146. PictureFileViewController *pictureVC = [[PictureFileViewController alloc] initWithNibName:nil bundle:nil];
  147. [self.navigationController pushViewController:pictureVC animated:NO];
  148. }else if ([titleStr isEqualToString:TS("password_change")]){ //修改密码
  149. PasswordViewController *passwordVC = [[PasswordViewController alloc] initWithNibName:nil bundle:nil];
  150. [self.navigationController pushViewController:passwordVC animated:NO];
  151. }else if ([titleStr isEqualToString:TS("device_storage")]){ //设备存储
  152. StorageViewController *storageVC = [[StorageViewController alloc] initWithNibName:nil bundle:nil];
  153. [self.navigationController pushViewController:storageVC animated:NO];
  154. }else if ([titleStr isEqualToString:TS("About_Device")]){ //关于设备
  155. AboutDeviceViewController *deviceVC = [[AboutDeviceViewController alloc] initWithNibName:nil bundle:nil];
  156. [self.navigationController pushViewController:deviceVC animated:NO];
  157. }else if ([titleStr isEqualToString:TS("Equipment_Update")]){ //设备升级
  158. UpgradeDeviceViewController *upgradeVC = [[UpgradeDeviceViewController alloc] initWithNibName:nil bundle:nil];
  159. [self.navigationController pushViewController:upgradeVC animated:NO];
  160. }else if ([titleStr isEqualToString:TS("Alarm_message_push")]){ //推送消息
  161. AlarmMessageViewController *alarmMessageVC = [[AlarmMessageViewController alloc] initWithNibName:nil bundle:nil];
  162. [self.navigationController pushViewController:alarmMessageVC animated:NO];
  163. }else if ([titleStr isEqualToString:TS("AnalyzeConfig")]){ //智能分析
  164. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  165. DeviceObject *object = [[DeviceControl getInstance] GetDeviceObjectBySN:channel.deviceMac];
  166. if(object.sysFunction.NewVideoAnalyze == NO){
  167. [SVProgressHUD showErrorWithStatus:TS("EE_MNETSDK_NOTSUPPORT")];
  168. return;
  169. }
  170. AnalyzerViewController *analyzeVC = [[AnalyzerViewController alloc] init];
  171. [self.navigationController pushViewController:analyzeVC animated:NO];
  172. }else if ([titleStr isEqualToString:TS("Encoding_format")]){ //视频格式
  173. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  174. DeviceObject *object = [[DeviceControl getInstance] GetDeviceObjectBySN:channel.deviceMac];
  175. if(object.sysFunction.SupportSmartH264 == NO){
  176. [SVProgressHUD showErrorWithStatus:TS("EE_MNETSDK_NOTSUPPORT")];
  177. return;
  178. }
  179. EncodingFormatViewController *formatVC = [[EncodingFormatViewController alloc] init];
  180. [self.navigationController pushViewController:formatVC animated:NO];
  181. }else if([titleStr isEqualToString:TS("Watermark_setting")]){ //水印
  182. WaterMarkViewController *waterMarkVC = [[WaterMarkViewController alloc] init];
  183. [self.navigationController pushViewController:waterMarkVC animated:NO];
  184. }else if([titleStr isEqualToString:TS("Cloud_storage")]){ //云服务
  185. CloudAbilityViewController *cloudVC = [[CloudAbilityViewController alloc] init];
  186. [self.navigationController pushViewController:cloudVC animated:NO];
  187. }else if([titleStr isEqualToString:TS("Buzzer_setting")]){
  188. BuzzerViewController *BuzzerVC = [[BuzzerViewController alloc] init];
  189. [self.navigationController pushViewController:BuzzerVC animated:NO];
  190. }else if([titleStr isEqualToString:TS("Sleep_time")]){
  191. /****
  192. * 获取和设置设备休眠时间 (目前只有部分设备支持休眠,例如门铃、门锁、猫眼、喂食器等等)
  193. *休眠时间单位为秒S,
  194. ***/
  195. ShutDownTimeViewController *timeVC = [[ShutDownTimeViewController alloc] init];
  196. [self.navigationController pushViewController:timeVC animated:NO];
  197. }else if([titleStr isEqualToString:TS("appEventHumanDetectAlarm")]){
  198. HumanDetectionViewController *humandetectVC = [[HumanDetectionViewController alloc] init];
  199. [self.navigationController pushViewController:humandetectVC animated:NO];
  200. }else if ([titleStr isEqualToString:TS("Sensor_Config")]){
  201. SensorlistVCViewController *vc = [[SensorlistVCViewController alloc] init];
  202. [self.navigationController pushViewController:vc animated:YES];
  203. }else{
  204. return;
  205. }
  206. }
  207. - (void)setNaviStyle {
  208. self.navigationItem.title = TS("setting");
  209. }
  210. - (void)configSubView {
  211. [self.view addSubview:self.devConfigTableView];
  212. }
  213. - (void)initDataSource {
  214. self.configTitleArray = @[
  215. @{@"title":TS("Encode_config"),@"detailInfo":@"在这里,你可以配置分辨率,帧数,音频,视频"},
  216. @{@"title":TS("alarm_config"),@"detailInfo":@"设备支持各种报警触发和联动,您可以在这里进行配置"},
  217. @{@"title":TS("Record_config"),@"detailInfo":@"在这里,你可以配置分辨率,帧数,音频,视频"},
  218. @{@"title":TS("picture_vonfig"),@"detailInfo":@"在这里,你可以配置分辨率,帧数,音频,视频"},
  219. @{@"title":TS("time_syn"),@"detailInfo":@"在这里可以显示和同步设备时间"},
  220. @{@"title":TS("device_storage"),@"detailInfo":@"该选项允许您查看和管理设备的存储空间"},
  221. @{@"title":TS("password_change"),@"detailInfo":@"您可以更改设备的访问密码"},
  222. @{@"title":TS("record_file"),@"detailInfo":@"设备端保存的普通录像和报警录像等等,必须有存储空间的设备才有录像"},
  223. @{@"title":TS("picture_file"),@"detailInfo":@"设备端保存的报警抓图等等,必须有存储空间的设备才有图片"},
  224. @{@"title":TS("Alarm_message_push"),@"detailInfo":@""},
  225. @{@"title":TS("About_Device"),@"detailInfo":@""},
  226. @{@"title":TS("Equipment_Update"),@"detailInfo":@""},
  227. @{@"title":TS("AnalyzeConfig"),@"detailInfo":@""},
  228. @{@"title":TS("Cloud_storage"),@"detailInfo":@""},
  229. @{@"title":TS("Encoding_format"),@"detailInfo":@""},
  230. @{@"title":TS("Watermark_setting"),@"detailInfo":@""},
  231. @{@"title":TS("Buzzer_setting"),@"detailInfo":@""},
  232. @{@"title":TS("Sleep_time"),@"detailInfo":@""},
  233. @{@"title":TS("appEventHumanDetectAlarm"),@"detailInfo":@""},
  234. @{@"title":@"GB配置",@"detailInfo":@""},
  235. @{@"title":@"Json和DevCmd调试",@"detailInfo":@""},
  236. @{@"title":@"鱼眼信息",@"detailInfo":@""},
  237. @{@"title":TS("Sensor_Config"),@"detailInfo":@""}];
  238. }
  239. @end