route_pi::route_pi(void *ppimgr) :opencpn_plugin_110(ppimgr) { // Create the PlugIn icons initialize_images(); // g_route_pi = this; }
watchdog_pi::watchdog_pi(void *ppimgr) : opencpn_plugin_110(ppimgr) { // Create the PlugIn icons initialize_images(); m_lastfix.Lat = NAN; m_lasttimerfix.Lat = NAN; m_sog = m_cog = NAN; g_ReceivedPathGUIDMessage = wxEmptyString; g_ReceivedBoundaryTimeMessage = wxEmptyString; g_ReceivedBoundaryDistanceMessage = wxEmptyString; g_ReceivedBoundaryAnchorMessage = wxEmptyString; g_ReceivedBoundaryGUIDMessage = wxEmptyString; g_ReceivedGuardZoneMessage = wxEmptyString; g_ReceivedGuardZoneGUIDMessage = wxEmptyString; g_ReceivedODVersionMessage = wxEmptyString; g_GuardZoneName = wxEmptyString; g_GuardZoneDescription = wxEmptyString; g_GuardZoneGUID = wxEmptyString; g_AISTarget.m_dLat = 0.; g_AISTarget.m_dLon = 0.; g_AISTarget.m_dSOG = 0.; g_AISTarget.m_dCOG = 0.; g_AISTarget.m_dHDG = 0.; g_AISTarget.m_iMMSI = 0; g_AISTarget.m_sShipName = wxEmptyString; g_watchdog_pi = this; }
gecomapi_pi::gecomapi_pi(void *ppimgr) :opencpn_plugin_113(ppimgr) { // Create the PlugIn icons initialize_images(); m_pgecomapi_window = NULL; }
grib_pi::grib_pi(void *ppimgr) :opencpn_plugin_112(ppimgr) { // Create the PlugIn icons initialize_images(); m_pLastTimelineSet = NULL; m_bShowGrib = false; }
locapi_pi::locapi_pi ( void *ppimgr ) : opencpn_plugin_16 ( ppimgr ), wxTimer ( this ) { // Create the PlugIn icons initialize_images(); m_interval = 1000; }
climatology_pi::climatology_pi(void *ppimgr) :opencpn_plugin_113(ppimgr) { m_pClimatologyDialog = nullptr; // Create the PlugIn icons initialize_images(); s_climatology_pi = this; }
weather_routing_pi::weather_routing_pi(void *ppimgr) :opencpn_plugin_110(ppimgr) { // Create the PlugIn icons initialize_images(); m_tCursorLatLon.Connect(wxEVT_TIMER, wxTimerEventHandler ( weather_routing_pi::OnCursorLatLonTimer ), NULL, this); }
objsearch_pi::objsearch_pi ( void *ppimgr ) : opencpn_plugin_112 ( ppimgr ) { // Create the PlugIn icons initialize_images(); m_db_thread_running = false; m_bDBUsable = true; m_bWaitForDB = true; finishing = false; m_db = initDB(); wxSQLite3ResultSet set; if (m_bDBUsable) { set = SelectFromDB( m_db, wxT("SELECT id, chartname, scale, nativescale FROM chart") ); if (m_bDBUsable) { while (set.NextRow()) { Chart ch; ch.id = set.GetInt(0); ch.name = set.GetAsString(1); ch.scale = set.GetDouble(2); ch.nativescale = set.GetInt(3); m_chartsInDb[ch.name] = ch; } } set.Finalize(); } if (m_bDBUsable) { set = SelectFromDB( m_db, wxT("SELECT id, featurename FROM feature")); if (m_bDBUsable) { while (set.NextRow()) { m_featuresInDb[set.GetAsString(1)] = set.GetInt(0); } } set.Finalize(); } m_bWaitForDB = false; }
iacfleet_pi::iacfleet_pi( void *ppimgr ) : opencpn_plugin_113( ppimgr ) { // Set some default private member parameters m_dialog_x = 0; m_dialog_y = 0; m_dialog_sx = 200; m_dialog_sy = 200; m_sort_type = SORT_NAME; m_dir = wxEmptyString; m_pDialog = NULL; m_pdc = NULL; m_bShowIcon = false; m_leftclick_tool_id = -1; // Get a pointer to the opencpn display canvas, to use as a parent for the GRIB dialog m_parent_window = GetOCPNCanvasWindow(); // Create the PlugIn icons initialize_images(); wxCurlBase::Init(); }
vdr_pi::vdr_pi(void *ppimgr) :opencpn_plugin_16(ppimgr), wxTimer(this) { // Create the PlugIn icons initialize_images(); }
calculator_pi::calculator_pi(void *ppimgr) :opencpn_plugin_18(ppimgr) { // Create the PlugIn icons initialize_images(); }
int main(int argc, char *argv[]) { /*set line buffering of stdout*/ setvbuf(stdout, NULL, _IOLBF, 0); int maxloops; if(argc == 1) maxloops = 100; else maxloops = atoi(argv[1]); printf("EVaura activated for %i mining loops\n", maxloops); /*Initialize random number generator*/ point rsult; points rsults = {0, NULL}; gsl_rng_default_seed = time(NULL); r = gsl_rng_alloc (gsl_rng_default); current_time = time(NULL); int shieldson = 0; int randompulse, pulsetimer; char number_of_belts = 0; char current_belt = 0; char is_belt_toast[20] = {0}; char unable_to_lock = 0; display = XOpenDisplay(NULL); // Open first (-best) display screen = DefaultScreenOfDisplay(display); assert(display); xdodisplay = xdo_new_with_opened_display (display,":0",1); xdo_window_select_with_click(xdodisplay, &EVEwindow); update_screenshot(); //obtain display properties initialize_images(); initialize_ore_tables(); ship *s = &mackinaw; for(int i = 0; i < maxloops; i++){ undock(); //Warp to belt click_on(&menu_belts_inactive, 1, ""); mysleep(500); update_screenshot(); number_of_belts = find_multiple(&aba_menu, NULL); if(number_of_belts < 1){ printf("No belts found!!!\n Docking!"); //dock(); //break; } else printf("We found %i belts\n", number_of_belts); //choose random belt which isn't already depleted while((current_belt = random_int(1, number_of_belts)) && is_belt_toast[(int)current_belt] == 1) { printf("We chosed %i. belt, but is is empty\n", current_belt); } if (findmatch(&menu_name, &rsult) == 0){ click(rsult.X + random_int(0,30), rsult.Y + 19*current_belt, 1, "s"); printf("Warping to %i. belt\n", current_belt); } if(random_int(0,3) > 1) { start_shields(s); shieldson = 1; } else shieldson = 0; wait_for_warp(s); //arrived to belt launch_drones(s); click_on(&menu_mining_inactive, 1, ""); mysleep(1500); lock_nearest_roid(); start_mining(&pulsetimer, &randompulse); if(shieldson == 0) start_shields(s); while(1){ sleep(1); update_screenshot(); if (findmatch(&full_cargo2, NULL) == 0) break; if (findmatch(&invalid_target, NULL) == 0) click_on(&OK, 1, ""); switch (check_roid_lock()) { case 0 : unable_to_lock++; if(unable_to_lock > 6){ printf("We were repeatedly unable to lock anything, this belt is probably toast\n"); //FIXME: this could probably also happen with pirates or roids too far to lock is_belt_toast[(int)current_belt] = 1; i--;//decrease counter, sice this loop wasnt finished goto dock; } printf("we didnt found any locked roids, attempting to lock one\n"); if (lock_best_roid() == 0) { start_mining(&pulsetimer, &randompulse); unable_to_lock = 0; } continue; case 1 : if(find_multiple(&i_mining_laser_active, &rsults) == 0){ start_mining(&pulsetimer, &randompulse); } lock_best_roid(); unable_to_lock = 0; continue; } switch (find_multiple(&i_mining_laser_active, &rsults)) { case 0 : printf("we have a locked roid however lasers were not active\n"); start_mining(&pulsetimer, &randompulse); continue; case 1 : xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5); //pulse random laser, if we are lucky we turn on the right one //if not, we will turn on both next time break; } sleep(2); if ( (time(NULL) - pulsetimer) > randompulse ) { printf("cycling lasers\n"); xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5); xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5); mysleep(1000); update_screenshot(); if (check_roid_lock() == 1) { mysleep(50); xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5); xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5); mysleep(random_int(100,300)); } else if(check_roid_lock() > 1 ){ mouse_move(locked_roids.rsult[0].X, locked_roids.rsult[0].Y); xdo_click(xdodisplay, CURRENTWINDOW, 1); xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5); mysleep(550); mouse_move(locked_roids.rsult[1].X, locked_roids.rsult[1].Y); xdo_click(xdodisplay, CURRENTWINDOW, 1); xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5); } pulsetimer = time(NULL); randompulse = random_int(50,150); } } dock: dock_drones(s);//we can dock while preparing to warp if (click_on(&menu_default_inactive, 1, "") == 0) { printf("defalut menu inactive, clicking on it\n"); mysleep(random_int(800,1200)); } else printf("default menu probably active, no need to click\n"); update_screenshot(); if(click_on(&aba_peace_station, 1, "d") == 0) { printf("found Aba station, attempting a warp\n"); } else printf ("Cant find Aba station, something bad is going on.\n"); wait_for_warp(s); mysleep(10000);//FIXME: new function wait for dock??? for (int i = 0; unload_ore(s) == 1; i++){ mysleep(5000); if(i > 4){ printf("Unable to unload ore\n"); goto exit; } } } exit: if(displayImage) cvReleaseImage(&displayImage); XCloseDisplay(display); return 0; }
findit_pi::findit_pi(void *ppimgr) :opencpn_plugin_19(ppimgr) { // Create the PlugIn icons initialize_images(); }
kmloverlay_pi::kmloverlay_pi(void *ppimgr) : opencpn_plugin_17(ppimgr) { // Create the PlugIn icons initialize_images(); }
ocpndebugger_pi::ocpndebugger_pi(void *ppimgr) : opencpn_plugin_114(ppimgr) { // Create the PlugIn icons initialize_images(); }
// Update Motion History Image: Calculate motion features and orientation. void motionDetection(IplImage* image, IplImage* destination_image, MotionInfo* motionInfo) { double timestamp = (double)clock()/CLOCKS_PER_SEC; // get current time in seconds CvSize image_size = cvSize(image->width, image->height); // get current frame image_size int previous_frame_index = last_index, current_frame_index; initialize_images(image_size); cvCvtColor(image, image_buffer[last_index], CV_BGR2GRAY); // convert frame to grayscale current_frame_index = (last_index + 1) % N; // index of (last_index - (N-1))th frame last_index = current_frame_index; silhouette = image_buffer[current_frame_index]; cvAbsDiff(image_buffer[previous_frame_index], image_buffer[current_frame_index], silhouette); // Get difference between frames cvThreshold(silhouette, silhouette, DIFFERENCE_THRESHOLD, 1, CV_THRESH_BINARY); // Add threshold //cvDilate(silhouette, silhouette, 0, 18); //cvErode(silhouette, silhouette, 0, 10); cvUpdateMotionHistory(silhouette, mhi, timestamp, MHI_DURATION); // Update MHI // Convert MHI to blue 8U image cvCvtScale(mhi, orientation_mask, 255./MHI_DURATION, (MHI_DURATION - timestamp)*255./MHI_DURATION); if (destination_image) { cvZero(destination_image); cvCvtPlaneToPix(orientation_mask, 0, 0, 0, destination_image); } // Calculate motion gradient orientation and valid orientation mask cvCalcMotionGradient(mhi, orientation_mask, orientation, MAX_TIME_DELTA, MIN_TIME_DELTA, 3); // motion_feature_sequence = extract_motion_features(); if(!storage) storage = cvCreateMemStorage(0); else cvClearMemStorage(storage); CvSeq* motion_feature_sequence = cvSegmentMotion(mhi, segment_mask, storage, timestamp, MAX_TIME_DELTA); int SEGMENT_WIDTH = image_size.width / MAX_SEGMENTS_X; int SEGMENT_HEIGHT = image_size.height / MAX_SEGMENTS_Y; // Global motion CvRect global_motion_segment = cvRect(0, 0, image_size.width, image_size.height); motionInfo->global_angle = calculate_orientation(global_motion_segment, silhouette); if (destination_image) draw_orientation(destination_image, &global_motion_segment, motionInfo->global_angle, 100, CV_RGB(0, 255, 0), true); long area = 0; long totalArea = 0; int totalMovingSegments = 0; bool hasValidMovement = false; CvRect segmentRect; // Segmented motion for(int x = 0; x < MAX_SEGMENTS_X; x++) { for(int y = 0; y < MAX_SEGMENTS_Y; y++) { segmentRect = cvRect(x * SEGMENT_WIDTH, y * SEGMENT_HEIGHT, SEGMENT_WIDTH, SEGMENT_HEIGHT); area = calculate_motion(&segmentRect, motion_feature_sequence); hasValidMovement = (area > MIN_MOTION_FEATURE_AREA); motionInfo->segment_motion_areas[x][y] = area; motionInfo->segment_movements[x][y] = hasValidMovement; motionInfo->segment_angles[x][y] = calculate_orientation(segmentRect, silhouette); totalArea += area; totalMovingSegments += (area > MIN_MOTION_FEATURE_AREA); //printf("%i, ", area); //fflush(stdout); if (hasValidMovement) if (destination_image) draw_orientation(destination_image, &segmentRect, motionInfo->segment_angles[x][y], 20, CV_RGB(255, 0, 0), true); } } motionInfo->total_motion_area = totalArea; motionInfo->total_segments_with_movements = totalMovingSegments; motionInfo->SEGMENTS_X = MAX_SEGMENTS_X; motionInfo->SEGMENTS_Y = MAX_SEGMENTS_Y; printf("%i, %f\n", totalArea, (float)totalArea / (float)(image_size.width*image_size.height)); //fflush(stdout); }