AboutDeviceViewController.mm 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // AboutDeviceViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/19.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "AboutDeviceViewController.h"
  9. #import "DeviceconfigTableViewCell.h"
  10. #import "SystemInfoConfig.h"
  11. #import "SystemResetConfig.h"
  12. @interface AboutDeviceViewController () <UITableViewDelegate,UITableViewDataSource,SystemInfoConfigDelegate>
  13. @property (nonatomic, strong) UITableView *devConfigTableView;
  14. @property (nonatomic, strong) NSMutableArray *configTitleArray;
  15. @property (nonatomic, strong) SystemInfoConfig *config;
  16. @property (nonatomic, strong) SystemResetConfig *resetConfig;
  17. @end
  18. @implementation AboutDeviceViewController
  19. - (UITableView *)devConfigTableView {
  20. if (!_devConfigTableView) {
  21. _devConfigTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  22. _devConfigTableView.delegate = self;
  23. _devConfigTableView.dataSource = self;
  24. _devConfigTableView.rowHeight = 60;
  25. [_devConfigTableView registerClass:[DeviceconfigTableViewCell class] forCellReuseIdentifier:@"cell"];
  26. }
  27. return _devConfigTableView;
  28. }
  29. #pragma mark -- viewDidLoad
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. //设置导航栏样式
  33. [self setNaviStyle];
  34. //初始化数据
  35. [self initDataSource];
  36. //配置子视图
  37. [self configSubView];
  38. //获取设备信息systeminfo
  39. [self getSysteminfo];
  40. }
  41. - (void)viewWillDisappear:(BOOL)animated{
  42. //有加载状态、则取消加载
  43. if ([SVProgressHUD isVisible]){
  44. [SVProgressHUD dismiss];
  45. }
  46. }
  47. //编码配置需要知道设备的模拟通道数量,所以在编码配置前需要获取一下
  48. - (void)getSysteminfo {
  49. if (_config == nil) {
  50. _config = [[SystemInfoConfig alloc] init];
  51. _config.delegate = self;
  52. }
  53. if (_resetConfig == nil){
  54. _resetConfig = [[SystemResetConfig alloc] init];
  55. }
  56. [SVProgressHUD show];
  57. [_config getSystemInfo];
  58. }
  59. #pragma mark 获取设备systeminfo回调
  60. - (void)SystemInfoConfigGetResult:(NSInteger)result {
  61. if (result >0) {
  62. //获取成功
  63. [SVProgressHUD dismiss];
  64. }else{
  65. //获取失败
  66. [MessageUI ShowErrorInt:(int)result];
  67. }
  68. }
  69. #pragma mark -- UITableViewDelegate/DataSource
  70. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  71. return self.configTitleArray.count;
  72. }
  73. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  74. DeviceconfigTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  75. if (!cell) {
  76. cell = [[DeviceconfigTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  77. }
  78. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  79. DeviceObject *device = [[DeviceControl getInstance] GetDeviceObjectBySN:channel.deviceMac];
  80. NSString *title = [self.configTitleArray[indexPath.row] objectForKey:@"title"];
  81. cell.Labeltext.text = title;
  82. if ([title isEqualToString:TS("serial_number2")]) {
  83. cell.detailLabel.text = device.deviceMac;
  84. }
  85. if ([title isEqualToString:TS("device_type2")]) {
  86. cell.detailLabel.text = [NSString getDeviceType:device.nType];
  87. }
  88. if ([title isEqualToString:TS("soft_version")]) {
  89. cell.detailLabel.text = device.info.softWareVersion;
  90. }
  91. if ([title isEqualToString:TS("hard_version")]) {
  92. cell.detailLabel.text = device.info.hardWare;
  93. }
  94. if ([title isEqualToString:TS("lastUpgreade_time")]) {
  95. cell.detailLabel.text = device.info.buildTime;
  96. }
  97. if ([title isEqualToString:TS("video_format")]) {
  98. cell.detailLabel.text = [NSString getDeviceNetType:device.info.netType];
  99. }
  100. return cell;
  101. }
  102. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  103. NSString *title = [self.configTitleArray[indexPath.row] objectForKey:@"title"];
  104. if ([title isEqualToString:TS("about_tip")]) { // 点击恢复出厂设置
  105. UIAlertController *alert = [UIAlertController alertControllerWithTitle:TS("warm_prompt") message:TS("reset_device") preferredStyle:UIAlertControllerStyleAlert];
  106. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:TS("Cancel") style:UIAlertActionStyleCancel handler:nil];
  107. UIAlertAction *comfirmAction = [UIAlertAction actionWithTitle:TS("OK") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  108. [self.resetConfig resetDeviceConfig];
  109. [SVProgressHUD show];
  110. }];
  111. [alert addAction:cancelAction];
  112. [alert addAction:comfirmAction];
  113. [self presentViewController:alert animated:YES completion:nil];
  114. }
  115. }
  116. - (void)setNaviStyle {
  117. self.navigationItem.title = TS("About_Device");
  118. }
  119. - (void)configSubView {
  120. [self.view addSubview:self.devConfigTableView];
  121. }
  122. - (void)initDataSource {
  123. self.configTitleArray = (NSMutableArray*)@[
  124. @{@"title":TS("serial_number2"),@"detailInfo":@""},
  125. @{@"title":TS("device_type2"),@"detailInfo":@""},
  126. @{@"title":TS("soft_version"),@"detailInfo":@""},
  127. @{@"title":TS("hard_version"),@"detailInfo":@""},
  128. @{@"title":TS("lastUpgreade_time"),@"detailInfo":@""},
  129. @{@"title":TS("video_format"),@"detailInfo":@""},
  130. @{@"title":TS("about_tip"),@"detailInfo":@""}];
  131. }
  132. - (void)didReceiveMemoryWarning {
  133. [super didReceiveMemoryWarning];
  134. // Dispose of any resources that can be recreated.
  135. }
  136. @end