CommonConfig.mm 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // CommonConfig.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/5/8.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "CommonConfig.h"
  9. #import "General_General.h"
  10. #import "General_Location.h"
  11. @interface CommonConfig ()
  12. {
  13. General_General generalInfo;
  14. General_Location location; //本地化配置,夏令时、日期格式 ,这个配置因为多处用到,所以专门放在这个common类中
  15. }
  16. @end
  17. @implementation CommonConfig
  18. #pragma mark - 获取本地化配置 GeneralGenera
  19. - (void)getGeneralGeneralConfig:(NSString *)deviceMac {
  20. CfgParam* paramGeneralInfo = [[CfgParam alloc] initWithName:[NSString stringWithUTF8String:generalInfo.Name()] andDevId:deviceMac andChannel:-1 andConfig:&generalInfo andOnce:YES andSaveLocal:NO];
  21. [self AddConfig:paramGeneralInfo];
  22. [self GetConfig:NSSTR(generalInfo.Name())];
  23. }
  24. #pragma mark - 获取本地化配置 GeneralLocation
  25. - (void)getGeneralLocationConfig {
  26. ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
  27. //通用配置,需要用到其中的视频制式参数
  28. [self AddConfig:[CfgParam initWithName:channel.deviceMac andConfig:&location andChannel:-1 andCfgType:CFG_GET]];
  29. //调用获取配置的命令
  30. [self GetConfig:NSSTR(location.Name())];
  31. }
  32. #pragma mark 保存本地化配置回调
  33. - (void)OnGetConfig:(CfgParam *)param {
  34. if ([param.name isEqualToString:[NSString stringWithUTF8String:generalInfo.Name()]]) {
  35. if (param.errorCode <= 0) {
  36. //获取失败
  37. }else{
  38. //获取成功
  39. }
  40. }
  41. if ([param.name isEqualToString:[NSString stringWithUTF8String:location.Name()]]) {
  42. if ([self.locationDelegate respondsToSelector:@selector(getGeneral_LocationConfigResult:)]) {
  43. [self.locationDelegate getGeneral_LocationConfigResult:param.errorCode];
  44. }
  45. }
  46. }
  47. #pragma mark - 保存本地化配置 GeneralLocation
  48. - (void)setGeneralLocationConfig {
  49. [self SetConfig:NSSTR(location.Name())];
  50. }
  51. #pragma mark 保存本地化配置回调
  52. -(void)OnSetConfig:(CfgParam *)param{
  53. if ([param.name isEqualToString:NSSTR(location.Name())]) {
  54. if ([self.locationDelegate respondsToSelector:@selector(setGeneral_LocationConfigResult:)]) {
  55. [self.locationDelegate setGeneral_LocationConfigResult:param.errorCode];
  56. }
  57. }
  58. }
  59. #pragma mark - 读取各项配置的属性值 - General_Location
  60. //获取视频制式
  61. - (NSString *)getVideoFormat {
  62. return NSSTR(location.VideoFormat.Value()) ;
  63. }
  64. //获取夏令时开关
  65. - (NSString*)getDSTRule {
  66. return NSSTR(location.DSTRule.Value());
  67. }
  68. #pragma mark - 设置各项配置的属性值 - General_Location
  69. - (void)setDSTRule:(NSString*)enable { //设置夏令时开关
  70. location.DSTRule = SZSTR(enable);
  71. }
  72. - (void)setmDSTStartYear:(int)year { //设置夏令时开始年份
  73. location.mDSTStart.Year = year;
  74. }
  75. - (void)setmDSTStartMonth:(int)month {//开始月份
  76. location.mDSTStart.Month =month;
  77. }
  78. - (void)setmDSTStartDay:(int)day {//开始日期
  79. location.mDSTStart.Day =day;
  80. }
  81. - (void)setmDSTEndYear:(int)year {//结束年份
  82. location.mDSTEnd.Year = year;
  83. }
  84. - (void)setmDSTEndMonth:(int)month {//月份
  85. location.mDSTEnd.Month = month;
  86. }
  87. - (void)setmDSTEndDay:(int)day {//日期
  88. location.mDSTEnd.Day = day;
  89. }
  90. @end