Motion


Motion은 3.0.0 버전 이상 부터 제공되며 해당 라이브러리를 추가하여 사용해야 된다.

Motion 는 디바이스의 Gyro 정보를 제공하는 기능이다.
확장 프레임워크 파일을 추가하여 사용할 수 있으며 추가 방법은 iOS 개발 가이드 의 내용을 참조한다.


getCurrent

현재 모션 정보를 얻어오는 기능이며 호출 방법은 다음과 같다.

Example

///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPMotion()
let infoParam = DAPMotionGetCurrentParam()
deviceAPI.execute(with: infoParam, completion: { (dict) in
   guard let resultDict = dict as NSDictionary? else {
       return
    }
   
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})


///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPMotion()
let params = [Any]()
deviceAPI.execute(withActionName: "getcurrent", params: params, completion: { (dict) in
   guard let resultDict = dict as NSDictionary? else {
       return
    }
   
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})

///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPMotion new];
DAPMotionGetCurrentParam *infoParam = [DAPMotionGetCurrentParam new];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
    ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:[resultDict objectForKey:kDeviceResult]];
    [self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
    [self showErrorDlgWithError:error];
}];


///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPMotion new];
[deviceAPI executeWithActionName:@"getCurrent" params:nil completion:^(NSDictionary *resultDict) {
    NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
    NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];

 

MotionData

필드설명
x단말의 x 값 
y단말의 y 값
z단말의 z 값
timestamp이벤트 발생 시간
  

watch

모션 모니터링 기능이며 호출 방법은 다음과 같다.

Example

///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPMotion()
let infoParam = DAPMotionWatchParam()
infoParam.delay = NSNumber(integerLiteral: 1)
infoParam.motionId = "1"
deviceAPI.execute(with: infoParam, completion: { (dict) in
   guard let resultDict = dict as NSDictionary? else {
       return
    }
   
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})


///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPMotion()
let params = ["watchKey", NSNumber(integerLiteral: 1)] as [Any]
deviceAPI.execute(withActionName: "watch", params: params, completion: { (dict) in
   guard let resultDict = dict as NSDictionary? else {
       return
    }
   
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})

///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPMotion new];
DAPMotionWatchParam *infoParam = [DAPMotionWatchParam new];
infoParam.motionId = @"watchKey";
infoParam.delay = [NSNumber numberWithInt:1];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
    ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:[resultDict objectForKey:kDeviceResult]];
    [self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
    [self showErrorDlgWithError:error];
}];

///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPMotion new];
NSArray *params = [NSArray arrayWithObjects:@"watchKey", [NSNumber numberWithInt:1], nil];
[deviceAPI executeWithActionName:@"watch" params:params completion:^(NSDictionary *resultDict) {
    NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
    NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];

 

MotionData

필드설명
x단말의 x 값 
y단말의 y 값
z단말의 z 값
timestamp이벤트 발생 시간
  

clearWatch

모션 모니터링 삭제 기능이며 호출 방법은 다음과 같다.

Example

///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPMotion()
let infoParam = DAPMotionClearWatchParam()
infoParam.watchId = "1"
deviceAPI.execute(with: infoParam, completion: { (dict) in
   guard let resultDict = dict as NSDictionary? else {
       return
    }
   
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})


///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPMotion()
let params = ["watchKey"]
deviceAPI.execute(withActionName: "clearWatch", params: params, completion: { (dict) in
   guard let resultDict = dict as NSDictionary? else {
       return
    }
   
}, failure: { (resultError) in
   guard let error = resultError else {
       return
    }
   
})

///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPMotion new];
DAPMotionClearWatchParam *infoParam = [DAPMotionClearWatchParam new];
infoParam.watchId = @"watchKey";
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
    ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:[resultDict objectForKey:kDeviceResult]];
    [self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
    [self showErrorDlgWithError:error];
}];

///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPMotion new];
NSArray *params = [NSArray arrayWithObjects:@"watchKey", nil];
[deviceAPI executeWithActionName:@"clearWatch" params:params completion:^(NSDictionary *resultDict) {
    NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
    NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];