ifish/Ifish/Utinitys/DataCenter/UserExtendataArchaver.m

273 lines
12 KiB
Objective-C

//
// UserExtendataArchaver.m
// Ifish
//
// Created by imac on 2017/6/9.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "UserExtendataArchaver.h"
@implementation UserExtendataArchaver
+(void)archiverRuiMeiDeviceCHInfo:(RuiMeiCHControl*)ch {
NSString *key = [NSString stringWithFormat:@"Ruimei%@",ch.macAd];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:ch toFile:file];
}
+(RuiMeiCHControl*)unArchiverRuiMeiDeviceCHInfo:(NSString *)mac {
NSString *key = [NSString stringWithFormat:@"Ruimei%@",mac];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
RuiMeiCHControl *ch = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
return ch;
}
+(void)archiverDeviceCHInfo:(RunSunCHControl*)ch
{
NSString *key = [NSString stringWithFormat:@"Rusun%@",ch.macAd];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:ch toFile:file];
}
+(RunSunCHControl*)unArchiverDeviceCHInfo:(NSString *)mac
{
NSString *key = [NSString stringWithFormat:@"Rusun%@",mac];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
RunSunCHControl *ch = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
return ch;
}
+(void)saveRuSunTmpname:(RunSunControlName *)nameModel{
NSString *key = [NSString stringWithFormat:@"RuSunTmp%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(RunSunControlName *)currentRuSunTemp:(NSString *)macaddress{
NSString *key = [NSString stringWithFormat:@"RuSunTmp%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
RunSunControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[RunSunControlName alloc] init];
controlName.light1 = @"灯1";
controlName.light2 = @"灯2";
controlName.pump = @"水泵";
controlName.JiaRe = @"加热棒";
controlName.macAddress = macaddress;
}
return controlName;
}
+(void)saveSongNuo86Name:(SongNuo86Name *)nameModel{
NSString *key = [NSString stringWithFormat:@"SongNuo%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(SongNuo86Name *)currentSongNuo86:(NSString *)macaddress{
NSString *key = [NSString stringWithFormat:@"SongNuo%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
SongNuo86Name *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[SongNuo86Name alloc] init];
controlName.light1 = @"灯1";
controlName.light2 = @"灯2";
controlName.waterPump = @"水泵";
controlName.airPump = @"氧泵";
controlName.guideng = @"柜灯";
controlName.jiaRe = @"加热棒";
controlName.macAddress = macaddress;
}
return controlName;
}
+(void)saveSongNuo128Name:(SongNuo128Name *)nameModel
{
NSString *key = [NSString stringWithFormat:@"SongNuo%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(SongNuo128Name *)currentSongNuo128:(NSString *)macaddress
{
NSString *key = [NSString stringWithFormat:@"SongNuo%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
SongNuo128Name *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[SongNuo128Name alloc] init];
controlName.light1 = @"灯1";
controlName.light2 = @"灯2";
controlName.waterPump = @"水泵";
controlName.airPump = @"氧泵";
controlName.uVPump = @"UV";
controlName.wave = @"造浪";
controlName.beiYong = @"备用";
controlName.jiaRe = @"加热棒";
controlName.macAddress = macaddress;
}
return controlName;
}
+(void)saveTwoControlName:(TwoControlName *)nameModel
{
NSString *key = [NSString stringWithFormat:@"Two%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(TwoControlName *)currentTwoControlName:(NSString *)macaddress
{
NSString *key = [NSString stringWithFormat:@"Two%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
TwoControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[TwoControlName alloc] init];
controlName.lightName = @"";
controlName.pumpName = @"水泵";
controlName.macAddress = macaddress;
}
return controlName;
}
+(void)saveThreeControlName:(ThreeControlName *)nameModel{
NSString *key = [NSString stringWithFormat:@"Three%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(ThreeControlName *)currentThreeControlName:(NSString *)macaddress
{
NSString *key = [NSString stringWithFormat:@"Three%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
ThreeControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[ThreeControlName alloc] init];
controlName.light1Name = @"灯1";
controlName.light2Name = @"灯2";
controlName.pumpName = @"UV/冲浪";
controlName.macAddress = macaddress;
}
return controlName;
}
+(void)saveFourControlName:(FourControlName *)nameModel
{
NSString *key = [NSString stringWithFormat:@"Four%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(FourControlName *)currentFourControlName:(NSString *)macaddress
{
NSString *key = [NSString stringWithFormat:@"Four%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
FourControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[FourControlName alloc] init];
controlName.light1 = @"灯1";
controlName.light2 = @"灯2";
controlName.uvName = @"UV";
controlName.pumpName = @"冲浪";
controlName.macAddress = macaddress;
}
return controlName;
}
+(void)saveXuToControlName:(XuToControlName *)nameModel
{
NSString *key = [NSString stringWithFormat:@"XuTo%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(XuToControlName *)currentXuToControlName:(NSString *)macaddress
{
NSString *key = [NSString stringWithFormat:@"XuTo%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
XuToControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[XuToControlName alloc] init];
controlName.airPump = @"气泵";
controlName.light1 = @"灯1";
controlName.light2 = @"灯2";
controlName.huLiDeng = @"护理灯";
controlName.waterPump = @"水泵";
controlName.jiaRe = @"加热棒";
controlName.macAddress = macaddress;
}
return controlName;
}
+(void)saveNewXuToControlName:(XuToControlName *)nameModel
{
NSString *key = [NSString stringWithFormat:@"newXuTo%@",nameModel.macAddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
[NSKeyedArchiver archiveRootObject:nameModel toFile:file];
}
+(XuToControlName *)currentNewXuToControlName:(NSString *)macaddress
{
NSString *key = [NSString stringWithFormat:@"newXuTo%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
XuToControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[XuToControlName alloc] init];
controlName.shajunLight = @"杀菌灯";
controlName.zengyangPump = @"增氧泵";
controlName.light1 = @"灯光1";
controlName.light2 = @"灯光2";
controlName.zaolangPump = @"造浪泵";
controlName.huLiDeng = @"护理灯";
controlName.xunhuanPump = @"循环泵";
controlName.jiaRe = @"加热棒";
controlName.macAddress = macaddress;
controlName.defaultName=@"1";
}
else
{
controlName.defaultName=@"";
}
return controlName;
}
+(XuToControlName *)currentPetsXuToControlName:(NSString *)macaddress
{
NSString *key = [NSString stringWithFormat:@"newXuTo%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
XuToControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[XuToControlName alloc] init];
controlName.shajunLight = @"杀菌灯";
controlName.zengyangPump = @"换气";
controlName.light1 = @"杀菌";
controlName.light2 = @"恒温";
controlName.zaolangPump = @"造浪泵";
controlName.huLiDeng = @"护理灯";
controlName.xunhuanPump = @"照明";
controlName.jiaRe = @"加热棒";
controlName.macAddress = macaddress;
}
return controlName;
}
@end