/// Stop a subsystem by name /// /// If the subsystem is not running, no change will be /// applied. /// /// The subsystem will be started during the next tick. /// This means there might be some delay. /// /// @throws NoSuchSubsystem void stop(const std::string &sub) { Subsystem::Register::EnsureExist(sub); next_tick([&, sub]() { if (is_running(sub)) subsystems.erase(sub); }); }
/// Start a subsystem by name /// /// If the subsystem is already running, no change will /// be done. /// /// The subsystem will be started during the next tick. /// This means there might be some delay. /// /// @throws NoSuchSubsystem void start(const std::string &sub) { Subsystem::Register::EnsureExist(sub); next_tick([&, sub]() { if (!is_running(sub)) subsystems[sub] = Subsystem::Register::Get(sub)(); }); }
//#### Member functions void Textgrafs::paint(){ //Used for continuous update //Refer to print for manual control if(next_tick()){ //Limit framerate print(); //Print out the current grid //save_old_grid(); } clear_grid(); //This empties the grid. You need to enter what you painted every frame }
bool_t _clockloop(clocktick_t *tick, struct timespec *res, clockloop_cb cb_func, void *cb_arg) { clockid_t clkid = CLOCK_REALTIME; debug("%s: start loop with res at %ds %dns\n", __FUNCTION__, res->tv_sec, res->tv_nsec); if (0 != clock_gettime(clkid, &(tick->time))) { perror("line: __LINE__ function: __FUNCTION__"); return FALSE; } while (CLOCK_STOP != cb_func(cb_arg)) next_tick(tick, res, clkid); return TRUE; }
void Ca_Y_Axis::draw_grid(){ if(!valid_)return; if(max_==min_)return; int tick_index=-1; double tick_value; int tick_order; double _interval=0; int l1,l2; int BD = 0; Fl_Widget * W_ = this; if(canvas_){ BD = canvas_->border(); W_ = canvas_; }else if(widget_){ W_ = widget_; } l1=W_->x()+Fl::box_dx(W_->box()); l2=W_->x()+W_->w()+Fl::box_dx(W_->box())-Fl::box_dw(W_->box()); int tcl; if(!(tcl=tick_length_)) tcl=label_font_size_; while(next_tick(tick_index, tick_value, tick_order,_interval)){ double _pos=position(tick_value); if(scale_&CA_REV){ if(_pos<min_pos_-BD) continue; if(_pos>max_pos_+BD) break; }else{ if(_pos<max_pos_-BD) break; if(_pos>min_pos_+BD) continue; } int grt; if((grt=grid_visible_&CA_LABEL_GRID) && !(tick_index % label_step_)){ fl_color(label_grid_color_); fl_line_style(label_grid_style_,label_grid_width_); if(grt==CA_LABEL_GRID){ fl_begin_loop(); fl_vertex(l1,_pos); fl_vertex(l2,_pos); fl_end_loop(); }else{ if(grt&CA_LEFT_LABEL_TICK){ fl_begin_loop(); fl_vertex(l1,_pos); fl_vertex(l1+tcl,_pos); fl_end_loop(); } if(grt&CA_RIGHT_LABEL_TICK){ fl_begin_loop(); fl_vertex(l2-tcl,_pos); fl_vertex(l2,_pos); fl_end_loop(); } } }else if((grt=grid_visible_&CA_MAJOR_GRID) && !(tick_index % major_step_)){ fl_color(major_grid_color_); fl_line_style(major_grid_style_,major_grid_width_); if(grt==CA_MAJOR_GRID){ fl_begin_loop(); fl_vertex(l1,_pos); fl_vertex(l2,_pos); fl_end_loop(); }else{ if(grt&CA_LEFT_MAJOR_TICK){ fl_begin_loop(); fl_vertex(l1,_pos); fl_vertex(l1+tcl,_pos); fl_end_loop(); } if(grt&CA_RIGHT_MAJOR_TICK){ fl_begin_loop(); fl_vertex(l2-tcl,_pos); fl_vertex(l2,_pos); fl_end_loop(); } } }else if((grt=(grid_visible_&CA_MINOR_GRID))){ fl_color(minor_grid_color_); fl_line_style(minor_grid_style_,minor_grid_width_); if(grt==CA_MINOR_GRID){ fl_begin_loop(); fl_vertex(l1,_pos); fl_vertex(l2,_pos); fl_end_loop(); }else{ if(grt&CA_LEFT_MINOR_TICK){ fl_begin_loop(); fl_vertex(l1,_pos); fl_vertex(l1+tcl/2,_pos); fl_end_loop(); } if(grt&CA_RIGHT_MINOR_TICK){ fl_begin_loop(); fl_vertex(l2-tcl/2,_pos); fl_vertex(l2,_pos); fl_end_loop(); } } } } fl_line_style(0,0); fl_color(FL_BLACK); };
void Ca_Y_Axis::draw(){ if(min_==max_) return; int BD = 0; Fl_Widget * W_ = this; if(canvas_){ BD = canvas_->border(); W_ = canvas_; }else if(widget_){ W_ = widget_; } int tick_index=-1; double tick_value; int tick_order;//,tick_number; double _interval=0; const char * label_format=label_format_; // if(damage()|FL_DAMAGE_ALL) // draw_label(); if (damage()&(FL_DAMAGE_ALL|CA_DAMAGE_ALL)){ update(); if (box()==FL_NO_BOX){ fl_color(parent()->color()); fl_rectf(x(),y(),w(),h()); }else draw_box(); if(!valid_) return; fl_font(label_font_face_,label_font_size_); int l1=0; int l2=0; int m1=0; int m2=0; int l=0; int _x=0; int _w,_h; //temporary coordinates for ticks double _pos,_y; //fl_clip(x()+Fl::box_dx(box()),y()+Fl::box_dy(box()),w()-Fl::box_dw(box()),h()-Fl::box_dh(box())); fl_color(axis_color_); int a=x()+Fl::box_dx(box())+border_; int b=a+w()-Fl::box_dw(box())-2*border_; switch(axis_align_ & CA_ALIGNMENT){ case CA_RIGHT: l=l1=m1=a; if(axis_align_&CA_NO_TICS) m2=m1; else if (tick_length_) m2=m1+tick_length_; else m2=m1+label_font_size_; l2=(l1+m2)/2; break; case CA_LEFT: l=l2=m2=b-1; if(axis_align_&CA_NO_TICS) m1=m2; else if (tick_length_) m1=m2-tick_length_; else m1=m2-label_font_size_; l1=(m1+m2)/2; break; case CA_CENTER: m1=a; m2=b; l=(a+b)/2; l1=(a+l)/2; l2=(l+b)/2; break; } fl_line_style(FL_SOLID|FL_CAP_FLAT,tick_width_); // double minp,maxp; double start_tick; double end_tick; bool tick_not_started = 1; while(next_tick(tick_index, tick_value, tick_order, _interval)){ _pos=position(tick_value); if(scale_&CA_REV){ if((_pos+1)<min_pos_-BD) continue; if((_pos-1)>max_pos_+BD) break; }else{ if((_pos+1)<max_pos_-BD) break; if((_pos-1)>min_pos_+BD) continue; } if(!(axis_align_&CA_NO_TICS)){ fl_begin_loop(); if(tick_index % major_step_){ fl_vertex(l1,_pos); fl_vertex(l2,_pos); }else{ fl_vertex(m1,_pos); fl_vertex(m2,_pos); } fl_end_loop(); if(tick_not_started){ tick_not_started = 0; start_tick = _pos; } end_tick = _pos; } if(!((tick_index % label_step_)|(axis_align_&CA_NO_LABELS))){ char label[MAX_LABEL_LENGTH]; char _label_format[MAX_LABEL_FORMAT]; if(!label_format){ int _tick_order; if (tick_order>=0) _tick_order=0; else _tick_order=-tick_order - 1; sprintf(_label_format,"%s.%if","%",_tick_order); } else strcpy(_label_format,label_format); sprintf(label, _label_format,tick_value); fl_measure(label,_w,_h); _y=_pos+_h/3; switch (axis_align_ & CA_ALIGNMENT){ case CA_LEFT: _x=m1-_h/3-_w; break; case CA_RIGHT: _x=m2+_h/3; break; case CA_CENTER: _x=(m1+m2)/2-_w/2; Fl_Color _color=fl_color(); fl_color(color()); ca_rectf(_x-_h/6,_pos-_h/2,_w+_h/3,_h); fl_color(_color); break; } ca_text(label,_x,_y); } } if((axis_align_ & CA_LINE) && !tick_not_started){ fl_begin_line(); fl_vertex(l,start_tick); fl_vertex(l,end_tick); //fl_vertex(l,W_->y()+Fl::box_dy(W_->box())); //fl_vertex(l,W_->y()+W_->h()+Fl::box_dy(W_->box())-Fl::box_dh(W_->box())); fl_end_line(); } fl_line_style(0); //fl_pop_clip(); } };
SWIGEXPORT void JNICALL Java_linuxclockJNI_next_1tick(JNIEnv *jenv, jclass jcls) { (void)jenv; (void)jcls; next_tick(); }
SWIGEXPORT void JNICALL Java_util_time_sequence_timerclock_nativelinux_linuxclockJNI_next_1tick(JNIEnv *jenv, jclass jcls) { (void)jenv; (void)jcls; next_tick(); }