• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <cstring>
17 #include <unistd.h>
18 
19 #include "client_executor/include/i_aie_client.inl"
20 #include "client_executor/include/i_client_cb.h"
21 #include "communication_adapter/include/sa_client.h"
22 #include "protocol/retcode_inner/aie_retcode_inner.h"
23 #include "protocol/struct_definition/aie_info_define.h"
24 #include "service_dead_cb.h"
25 #include "utils/log/aie_log.h"
26 
27 using namespace OHOS::AI;
28 
29 namespace {
30     unsigned char g_inputCharacter[] = "inputData";
31     const char * const CONFIG_DESCRIPTION = "config information";
32     const int INTERVAL = 10;
33     const long long CLIENT_INFO_VERSION = 1;
34     const int EXTEND_LENGTH = 10;
35     const long long ALGORITHM_INFO_CLIENT_VERSION = 2;
36     const int ALGORITHM_TYPE = 66;
37     const long long ALGORITHM_VERSION = 2;
38     const int OPERATE_ID = 2;
39     const int REQUEST_ID = 3;
40 }
41 
main()42 int main()
43 {
44     unsigned char *inputData = g_inputCharacter;
45 
46     ConfigInfo configInfo {.description = CONFIG_DESCRIPTION};
47     ClientInfo clientInfo = {
48         .clientVersion = CLIENT_INFO_VERSION,
49         .clientId = -1,
50         .sessionId = -1,
51         .serverUid = INVALID_UID,
52         .clientUid = INVALID_UID,
53         .extendLen = EXTEND_LENGTH,
54         .extendMsg = inputData,
55     };
56 
57     AlgorithmInfo algoInfo = {
58         .clientVersion = ALGORITHM_INFO_CLIENT_VERSION,
59         .isAsync = true,
60         .algorithmType = ALGORITHM_TYPE,
61         .algorithmVersion = ALGORITHM_VERSION,
62         .isCloud = true,
63         .operateId = OPERATE_ID,
64         .requestId = REQUEST_ID,
65         .extendLen = EXTEND_LENGTH,
66         .extendMsg = inputData,
67     };
68 
69     ServiceDeadCb cb = ServiceDeadCb();
70     int resultCode = AieClientInit(configInfo, clientInfo, algoInfo, &cb);
71     HILOGI("[Test]TestAieClientInit001 result is [%d][clientID:%d][sessionId:%d].",
72         resultCode, clientInfo.clientId, clientInfo.sessionId);
73 
74     clientInfo.sessionId = -1;
75     ServiceDeadCb callBack = ServiceDeadCb();
76     resultCode = AieClientInit(configInfo, clientInfo, algoInfo, &callBack);
77     HILOGI("[Test]TestAieClientInit001 result is [%d][clientID:%d][sessionId:%d].",
78         resultCode, clientInfo.clientId, clientInfo.sessionId);
79     sleep(INTERVAL);
80 }
81