35 StApi::IStDeviceReleasable *dev,
37 const std::string &camera_namespace,
54 omronsentech_camera::GetGigEIP::Request &req,
55 omronsentech_camera::GetGigEIP::Response &res)
59 GenApi::CNodeMapPtr p_nodemap_iface(
60 tl_dev_->GetIStInterface()->GetIStPort()->GetINodeMap());
61 GenApi::CIntegerPtr p_integer_ip_iface(
62 p_nodemap_iface->GetNode(
"GevInterfaceSubnetIPAddress"));
63 GenApi::CIntegerPtr p_integer_subnet_iface(
64 p_nodemap_iface->GetNode(
"GevInterfaceSubnetMask"));
65 GenApi::CIntegerPtr p_integer_gw_iface(
66 p_nodemap_iface->GetNode(
"GevInterfaceGateway"));
67 res.if_ip_address = p_integer_ip_iface->ToString();
68 res.if_ip_mask = p_integer_subnet_iface->ToString();
69 res.if_ip_gateway = p_integer_gw_iface->ToString();
72 GenApi::CNodeMapPtr p_nodemap_dev(
73 tl_dev_->GetLocalIStPort()->GetINodeMap());
74 GenApi::CIntegerPtr p_integer_ip_dev(
75 p_nodemap_dev->GetNode(
"GevDeviceIPAddress"));
76 GenApi::CIntegerPtr p_integer_subnet_dev(
77 p_nodemap_dev->GetNode(
"GevDeviceSubnetMask"));
78 GenApi::CIntegerPtr p_integer_gw_dev(
79 p_nodemap_dev->GetNode(
"GevDeviceGateway"));
80 res.dev_ip_address = p_integer_ip_dev->ToString();
81 res.dev_ip_mask = p_integer_subnet_dev->ToString();
82 res.dev_ip_gateway = p_integer_gw_dev->ToString();
89 omronsentech_camera::SetGigEIP::Request &req,
90 omronsentech_camera::SetGigEIP::Response &res)
99 StApi::IStInterface *p_iface =
tl_dev_->GetIStInterface();
100 if (p_iface->GetIStInterfaceInfo()->GetTLType().compare(TLTypeGEVName) !=
107 GenApi::CNodeMapPtr p_nodemap(p_iface->GetIStPort()->GetINodeMap());
108 GenApi::CIntegerPtr p_dev_selector(p_nodemap->GetNode(
"DeviceSelector"));
109 GenICam::gcstring strMyID =
tl_dev_->GetIStDeviceInfo()->GetID();
110 const int64_t max_index = p_dev_selector->GetMax();
111 for (int64_t k = 0; k <= max_index; k++)
113 p_dev_selector->SetValue(k);
114 GenApi::CStringPtr p_device_id(p_nodemap->GetNode(
"DeviceID"));
115 GenICam::gcstring strDeviceID = p_device_id->GetValue();
117 if (strDeviceID.compare(strMyID.c_str()) != 0)
continue;
126 for (
int i = 0; i < 3; i++)
129 for (MapCallback::iterator it = cb->begin(); it != cb->end(); it++)
131 StApi::IStRegisteredCallbackReleasable *cbf = it->second.cb_;
133 MapPublisher::iterator itpub =
148 GenApi::CIntegerPtr p_integer_ip(
149 p_nodemap->GetNode(
"GevDeviceForceIPAddress"));
150 GenApi::CIntegerPtr p_integer_subnet(
151 p_nodemap->GetNode(
"GevDeviceForceSubnetMask"));
152 GenApi::CIntegerPtr p_integer_gw(
153 p_nodemap->GetNode(
"GevDeviceForceGateway"));
154 GenApi::CCommandPtr p_command(
155 p_nodemap->GetNode(
"GevDeviceForceIP"));
157 p_integer_ip->SetValue(ntohl(inet_addr(req.ip_address.c_str())));
158 p_integer_subnet->SetValue(ntohl(inet_addr(req.ip_mask.c_str())));
159 p_integer_gw->SetValue(ntohl(inet_addr(req.ip_gateway.c_str())));
160 p_command->Execute();
162 p_iface->UpdateDeviceList();
165 tl_dev_.Reset(p_iface->CreateIStDevice(strMyID,
166 GenTL::DEVICE_ACCESS_CONTROL));
171 StApi::RegisterCallback(
tl_ds_, *
this,
175 if (
tl_dev_->GetIStInterface()->GetIStSystem()->GetStSystemVendor() ==
176 StApi::StSystemVendor_Sentech)
181 std::string callback_node =
"EventDeviceLost";
182 GenApi::CNodeMapPtr p(
tl_dev_->GetLocalIStPort()->GetINodeMap());
183 GenApi::CNodePtr node_callback(p->GetNode(callback_node.c_str()));
184 stc.
cb_ = StApi::RegisterCallback(node_callback, *
this,
187 GenApi::CEnumerationPtr p_event_selector(p->GetNode(
"EventSelector"));
188 GenApi::CEnumEntryPtr p_event_selector_entry(
189 p_event_selector->GetEntryByName(
"DeviceLost"));
190 p_event_selector->SetIntValue(p_event_selector_entry->GetValue());
191 GenApi::CEnumerationPtr p_event_notif(
192 p->GetNode(
"EventNotification"));
193 GenApi::CEnumEntryPtr p_event_notif_entry(
194 p_event_notif->GetEntryByName(
"On"));
195 p_event_notif->SetIntValue(p_event_notif_entry->GetValue());
196 tl_dev_->StartEventAcquisitionThread();
202 GenApi::CNodeMapPtr mp =
tl_dev_->GetRemoteIStPort()->GetINodeMap();
203 GenApi::INode *node_sel = mp->GetNode(
"ChunkSelector");
204 GenApi::INode *node_enable = mp->GetNode(
"ChunkEnable");
205 if (node_sel && node_enable)
207 GenApi::CEnumerationPtr chunk_selector(node_sel);
208 GenApi::NodeList_t nodelist;
209 chunk_selector->GetEntries(nodelist);
210 for (GenApi::NodeList_t::iterator it = nodelist.begin();
211 it != nodelist.end(); it++)
213 if (GenApi::IsAvailable(*it))
215 GenApi::CEnumEntryPtr enum_entry(*it);
216 std::string chunk_name = enum_entry->GetSymbolic().c_str();
217 chunk_selector->SetIntValue(enum_entry->GetValue());
218 GenApi::CBooleanPtr chunk_enable(node_enable);
219 if (GenApi::IsReadable(chunk_enable) &&
220 chunk_enable->GetValue() ==
true)
222 GenICam::gcstring chunk_value_name(
"Chunk");
223 chunk_value_name.append(chunk_name.c_str());
224 GenApi::CNodePtr p_chunk_value(mp->GetNode(chunk_value_name));
225 if (!p_chunk_value)
continue;
226 MapChunk::iterator itm =
map_chunk_.find(p_chunk_value
227 ->GetName().c_str());
228 if (itm ==
map_chunk_.end() || itm->second ==
nullptr)
230 map_chunk_[p_chunk_value->GetName().c_str()] = p_chunk_value;
236 ROS_INFO(
"IP Address of the GigE Camera has been updated. " 237 "You have to re-register any custom callback event.");
StApi::IStRegisteredCallbackReleasable * cb_
Class to control a connected GigEVision camera.
#define ACQ_ALREADY_ON_ERROR
MapCallback map_event_localdevice_
MapCallback map_event_remotedevice_
StApi::CIStDataStreamPtr tl_ds_
bool bool_event_datastream_
bool bool_acquisition_is_started_
bool setIPCallback(omronsentech_camera::SetGigEIP::Request &req, omronsentech_camera::SetGigEIP::Response &res)
#define CHECK_NULLPTR(P, X, MSG)
#define ACQ_ALREADY_ON_ERROR_STR
bool getIPCallback(omronsentech_camera::GetGigEIP::Request &req, omronsentech_camera::GetGigEIP::Response &res)
StApi::CIStDevicePtr tl_dev_
std::mutex mtx_acquisition_
MapCallback map_event_datastream_
std::map< std::string, struct StCallback > MapCallback
Base class to control a connected camera.
virtual ~StCameraInterfaceGEV()
Class to handle ROS parameter.
void eventDataStreamCB(StApi::IStCallbackParamBase *p, void *pvContext)
#define CATCH_COMMON_ERR()
MapPublisher map_msg_event_
StCameraInterfaceGEV(StApi::IStDeviceReleasable *dev, ros::NodeHandle nh_parent, const std::string &camera_namespace, StParameter *param, uint32_t queue_size=STCAMERA_QUEUE_SIZE)
void eventGenApiNodeCB(GenApi::INode *p, void *pvContext)
Class to control a connected GigEVision camera.