Debian Codegraph @

src/ArvFactory.cpp

raw
1 /*
2 GigE interface wrapper on araviss
3 Copyright (C) 2016 Hendrik Beijeman ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 #include "ArvGeneric.h"
20 #include "BlackFly.h"
21
22 #ifndef _GNU_SOURCE
23 #define _GNU_SOURCE
24 #endif
25 #include <string.h>
26
27 #define BLACKFLY_MODEL "BFLY-PGE-31S4M"
28
29 arv::ArvCamera *ArvFactory::find_first_available(void)
30 {
31 GError *error = NULL;
32 ::ArvCamera *camera = arv_camera_new(nullptr, &error);
33 const char *model_name = arv_camera_get_model_name(camera, &error);
34
35 if ((camera == nullptr) || (model_name == nullptr))
36 return nullptr;
37
38 if (memmem(model_name, strlen(model_name), BLACKFLY_MODEL, strlen(BLACKFLY_MODEL)))
39 {
40 printf("Creating BlackFly...\n");
41 return new BlackFly((void *)camera);
42 }
43 else
44 {
45 printf("Creating Generic...\n");
46 return new ArvGeneric((void *)camera);
47 }
48 }