Steffen Pohle 2 years ago
parent 7274530fae
commit 06d5235c63

@ -75,7 +75,8 @@ struct PosCtl_ThreadData {
position_2d c[2];
position_2d a1[2];
position_2d a2[2];
int mode;
position_2d target_pos;
int calib_mode;
};
@ -223,4 +224,6 @@ public:
void Thread();
};
extern struct PosCtl_ThreadData posctl_threaddata;
#endif

@ -18,7 +18,8 @@
enum {
VID_ENTERDATA_NONE = 0,
VID_ENTERDATA_POS
VID_ENTERDATA_POS,
VID_ENTERDATA_SETDEST
};
#define BUILDER_FILE "simpleskycam.ui"
@ -192,6 +193,7 @@ G_MODULE_EXPORT void cb_posctl_show (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_posctl_show_window (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_posctl_btncalib (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_posctl_btnstop (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_posctl_btnsetdest (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_posctl_btncontrol (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_posctl_entryanglelen (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_posctl_change_entry (GtkWidget *widget, gpointer data);
@ -201,6 +203,7 @@ G_MODULE_EXPORT void cb_posctl_angles_draw (GtkWidget *area, cairo_t *cr, int w,
G_MODULE_EXPORT void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data);
G_MODULE_EXPORT void cb_posctl_track_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data);
//
// menu elements
G_MODULE_EXPORT void cb_menu_set_rgbenc (GtkCheckMenuItem *checkmenuitem, gpointer user_data);

@ -23,6 +23,7 @@
#include "windows.h"
#endif
extern int video_enterdata;
extern PosCtl posctl;
extern Simulation simulation;
@ -46,7 +47,7 @@ struct AxisHistory {
struct AxisHistory axis_history[2][AXIS_HISTORY_CNT];
int axis_history_pos[2] = { 0, 0 };
struct PosCtl_ThreadData posctl_calib_debug;
struct PosCtl_ThreadData posctl_threaddata;
void axis_history_add(int axis, double diff, double out) {
if (axis > 1 || axis < 0) return;
@ -114,11 +115,19 @@ void cb_menu_set_displaycalibdata(GtkCheckMenuItem *checkmenuitem, gpointer use
void cb_posctl_show (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
posctl_calib_debug.mode = -1;
posctl_threaddata.calib_mode = -1;
posctl_threaddata.target_pos.x = -1;
posctl_threaddata.target_pos.y = -1;
posctl_gui_update();
}
void cb_posctl_btnsetdest (GtkWidget *widget, gpointer data) {
video_enterdata = VID_ENTERDATA_SETDEST;
};
void cb_posctl_btn_axismove (GtkWidget *widget, gpointer data) {
GtkWidget *btn_ramin = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_btn_ra_min"));
GtkWidget *btn_racenter = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "posctl_btn_ra_center"));
@ -344,7 +353,7 @@ void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
double dx, dy;
double aoutmin[2];
double aoutmax[2];
char txt[255];
int clienth = gtk_widget_get_allocated_height(area);
int clientw = gtk_widget_get_allocated_width(area);
@ -365,8 +374,8 @@ void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
cairo_stroke(cr);
cairo_set_dash(cr, NULL, 0, 0);
if (dra == area) axis = 0;
else if (ddec == area) axis = 1;
if (dra == area) axis = 1;
else if (ddec == area) axis = 0;
else {
cairo_move_to(cr, 30, 0);
cairo_show_text(cr, (char *)"unknown");
@ -408,6 +417,7 @@ void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
cairo_set_font_size (cr, 10);
cairo_move_to(cr, 60, 10);
cairo_show_text(cr, (char *)"out");
// draw elements diff
i = axis_history_pos[axis];
cnt = 0;
@ -418,8 +428,8 @@ void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
if (dx >= clientw) dx = clientw-1;
if (dy >= clienth) dy = clienth-1;
if (dx < 0) dx = 0;
if (dy < 0) dy = 0;
if (dx < 0) dx = 1;
if (dy < 0) dy = 1;
if (cnt == 0) cairo_move_to(cr, (int)dx, int(dy));
else cairo_line_to(cr, (int)dx, int(dy));
@ -429,6 +439,16 @@ void cb_posctl_axis_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
if (i < 0) i = AXIS_HISTORY_CNT-1;
} while (i != axis_history_pos[axis]);
cairo_stroke(cr);
// draw min and max
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_move_to(cr, 0, clienth-7);
snprintf (txt, 255, "%2.2f", aoutmin[axis]);
cairo_show_text(cr, txt);
cairo_move_to(cr, clientw-25, clienth-7);
snprintf (txt, 255, "%2.2f", aoutmax[axis]);
cairo_show_text(cr, txt);
cairo_stroke(cr);
};
@ -571,7 +591,6 @@ void posctl_gui_update() {
const gchar *txtptr = gtk_entry_get_text(GTK_ENTRY(e_posdevice));
if (strncmp(txtptr, "SIMULATION", 11) == 0) gtk_widget_show (btnsimreset);
else gtk_widget_hide (btnsimreset);
posctl.UnLockMutex();
}
@ -595,10 +614,10 @@ gboolean cb_thread_posctl (gpointer data) {
gdk_window_invalidate_rect(gtk_widget_get_window(posctl_rot_da), NULL, true);
if (data != NULL) {
posctl_calib_debug = *(struct PosCtl_ThreadData*) data;
posctl_threaddata = *(struct PosCtl_ThreadData*) data;
free (data);
switch (posctl_calib_debug.mode) {
switch (posctl_threaddata.calib_mode) {
case (POSCTL_CALIB_MODE_STOP1):
tg = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cal_mode_rs"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tg), true);
@ -668,7 +687,10 @@ void PosCtl::Stop() {
void PosCtl::NotifyGtk() {
int i;
struct PosCtl_ThreadData *data = (struct PosCtl_ThreadData*) malloc(sizeof(struct PosCtl_ThreadData));
threaddata.mode = calib_mode;
threaddata.calib_mode = calib_mode;
threaddata.target_pos.x = target_pos.x;
threaddata.target_pos.y = target_pos.y;
switch (calib_mode) {
case(POSCTL_CALIB_MODE_STOP1):
for (i = 0; i < 2; i++) {
@ -920,6 +942,7 @@ void PosCtl::Loop (int posx, int posy) {
NotifyGtk();
break;
}
NotifyGtk();
}
//
@ -977,6 +1000,7 @@ void PosCtl::Loop (int posx, int posy) {
#ifdef DEBUG_POSCTL
lastmode = mode;
#endif
};

@ -221,28 +221,24 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="baseline-position">top</property>
<child>
<object class="GtkExpander">
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="can-focus">False</property>
<property name="margin-start">4</property>
<property name="label-xalign">0</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkBox">
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="left-padding">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@ -250,64 +246,48 @@
<property name="halign">start</property>
<property name="valign">start</property>
<child>
<object class="GtkLabel">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-right">8</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="label" translatable="yes">Helligkeit Grenze:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="detect-scale-bright">
<property name="width-request">75</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="adjustment">detect-pos-adjbright</property>
<property name="lower-stepper-sensitivity">on</property>
<property name="upper-stepper-sensitivity">on</property>
<property name="show-fill-level">True</property>
<property name="fill-level">255</property>
<property name="round-digits">1</property>
<signal name="value-changed" handler="cb_detect_bright" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="detect-pos-cboff">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="draw-indicator">True</property>
<signal name="toggled" handler="cb_detect_detecttype" swapped="no"/>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-right">8</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="label" translatable="yes">Helligkeit Grenze:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="detect-scale-bright">
<property name="width-request">75</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="adjustment">detect-pos-adjbright</property>
<property name="lower-stepper-sensitivity">on</property>
<property name="upper-stepper-sensitivity">on</property>
<property name="show-fill-level">True</property>
<property name="fill-level">255</property>
<property name="round-digits">1</property>
<signal name="value-changed" handler="cb_detect_bright" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -316,118 +296,55 @@
</packing>
</child>
<child>
<object class="GtkRadioButton" id="detect-pos-cbbright">
<property name="label" translatable="yes">Brightest Point</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">detect-pos-cboff</property>
<signal name="toggled" handler="cb_detect_detecttype" swapped="no"/>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="detect-pos-cboff">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="draw-indicator">True</property>
<signal name="toggled" handler="cb_detect_detecttype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="detect-pos-cbbright">
<property name="label" translatable="yes">Brightest Point</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">detect-pos-cboff</property>
<signal name="toggled" handler="cb_detect_detecttype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">8</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">8</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Detect Object</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkExpander">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="detect-type-indet0">
<property name="label" translatable="yes">OFF</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet1</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="detect-type-indet1">
<property name="label" translatable="yes">Brightest Point</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet0</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="detect-type-indet2">
<property name="label" translatable="yes">InputDetectCrossC</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet0</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
@ -435,9 +352,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Follow Object</property>
<property name="label" translatable="yes">Detect</property>
</object>
</child>
</object>
@ -448,27 +363,33 @@
</packing>
</child>
<child>
<object class="GtkExpander">
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="can-focus">False</property>
<property name="margin-start">4</property>
<property name="label-xalign">0</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkBox">
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="orientation">vertical</property>
<property name="left-padding">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<object class="GtkRadioButton" id="detect-type-indet0">
<property name="label" translatable="yes">OFF</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Destination Position:</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet1</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -477,20 +398,15 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="detect_entry_destX">
<object class="GtkRadioButton" id="detect-type-indet1">
<property name="label" translatable="yes">Brightest Point</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="margin-left">4</property>
<property name="margin-right">4</property>
<property name="margin-start">4</property>
<property name="margin-end">4</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="max-length">5</property>
<property name="width-chars">5</property>
<property name="max-width-chars">5</property>
<property name="input-purpose">digits</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet0</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -499,100 +415,23 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkRadioButton" id="detect-type-indet2">
<property name="label" translatable="yes">InputDetectCrossC</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">,</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="detect_entry_destY">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="margin-left">4</property>
<property name="margin-right">4</property>
<property name="margin-start">4</property>
<property name="margin-end">4</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="width-chars">5</property>
<property name="max-width-chars">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="detect-btnsetdest">
<property name="label" translatable="yes">Set Dest</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-left">8</property>
<property name="margin-right">8</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="btnposctlconfig">
<property name="label" translatable="yes">Configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet0</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
@ -600,9 +439,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Position Control</property>
<property name="label" translatable="yes">Follow Object</property>
</object>
</child>
</object>
@ -615,7 +452,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@ -645,6 +482,11 @@
</object>
</child>
</object>
<object class="GtkImage" id="image-setdest">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-close</property>
</object>
<object class="GtkImage" id="image_control">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -1790,135 +1632,256 @@
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Values</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<!-- n-columns=4 n-rows=3 -->
<object class="GtkGrid">
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-spacing">4</property>
<property name="column-spacing">4</property>
<property name="label-xalign">0</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkLabel">
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Axis RA:</property>
<property name="left-padding">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Values</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<!-- n-columns=4 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-spacing">4</property>
<property name="column-spacing">4</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Axis RA:</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Axis DEC:</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">d</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">out</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_d_ra">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_d_dec">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_out_ra">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_out_dec">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Axis DEC:</property>
<property name="label" translatable="yes">Control Values</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkLabel">
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">d</property>
<property name="left-padding">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="posctl_stddestpos">
<property name="label" translatable="yes">Set Position</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image-setdest</property>
<property name="always-show-image">True</property>
<signal name="activate" handler="cb_posctl_btnsetdest" swapped="no"/>
<signal name="pressed" handler="cb_posctl_btnsetdest" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="posctl_cb_pvsptracking">
<property name="label" translatable="yes">PV - SP Tracking</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">out</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_d_ra">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_d_dec">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
<property name="label" translatable="yes">Position</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_out_ra">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="posctl_lb_out_dec">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">---</property>
<attributes>
<attribute name="style" value="oblique"/>
</attributes>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>

@ -31,8 +31,6 @@ extern position_2d video_enterdata_pos;
extern detect_movement detectedpos_data;
extern Configuration config;
extern struct PosCtl_ThreadData posctl_calib_debug;
void videoctrl_grid_delete ();
void videoctrl_grid_build ();
@ -157,6 +155,38 @@ void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data)
g_object_unref (pixbuf);
//
// need to draw the new destination?
if (video_enterdata == VID_ENTERDATA_SETDEST) {
color.blue = 1.0;
color.red = 0.0;
color.green = 1.0;
color.alpha = 1.0;
gdk_cairo_set_source_rgba(cr, &color);
cairo_move_to(cr, S_X(video_enterdata_pos.x)-10, S_Y(video_enterdata_pos.y)-10);
cairo_line_to(cr, S_X(video_enterdata_pos.x)+10, S_Y(video_enterdata_pos.y)+10);
cairo_move_to(cr, S_X(video_enterdata_pos.x)+10, S_Y(video_enterdata_pos.y)-10);
cairo_line_to(cr, S_X(video_enterdata_pos.x)-10, S_Y(video_enterdata_pos.y)+10);
cairo_stroke(cr);
}
else if (posctl_threaddata.target_pos.x != -1 and posctl_threaddata.target_pos.y != -1) {
color.blue = 0.0;
color.red = 0.0;
color.green = 0.5;
color.alpha = 1.0;
gdk_cairo_set_source_rgba(cr, &color);
cairo_move_to(cr, S_X(posctl_threaddata.target_pos.x), S_Y(posctl_threaddata.target_pos.y)-5);
cairo_line_to(cr, S_X(posctl_threaddata.target_pos.x), S_Y(posctl_threaddata.target_pos.y)+5);
cairo_move_to(cr, S_X(posctl_threaddata.target_pos.x)-5, S_Y(posctl_threaddata.target_pos.y));
cairo_line_to(cr, S_X(posctl_threaddata.target_pos.x)+5, S_Y(posctl_threaddata.target_pos.y));
cairo_stroke(cr);
}
//
// need to draw the select new position cross
if (video_enterdata == VID_ENTERDATA_POS) {
@ -241,37 +271,37 @@ void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data)
gtk_label_set_text(GTK_LABEL(lbY), txt2);
if (config.GetCalibrationShowData()) {
// printf ("%s:%d posctl_calib_debug.c : %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_calib_debug.c[0].x, posctl_calib_debug.c[0].y,
// posctl_calib_debug.c[1].x, posctl_calib_debug.c[1].y);
// printf ("%s:%d posctl_calib_debug.a1: %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_calib_debug.a1[0].x, posctl_calib_debug.a1[0].y,
// posctl_calib_debug.a1[1].x, posctl_calib_debug.a1[1].y);
// printf ("%s:%d posctl_calib_debug.a2: %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_calib_debug.a2[0].x, posctl_calib_debug.a2[0].y,
// posctl_calib_debug.a2[1].x, posctl_calib_debug.a2[1].y);
if (posctl_calib_debug.c[0].x != -1 && posctl_calib_debug.c[0].y != -1 &&
posctl_calib_debug.c[1].x != -1 && posctl_calib_debug.c[1].y != -1) {
// printf ("%s:%d posctl_threaddata.c : %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_threaddata.c[0].x, posctl_threaddata.c[0].y,
// posctl_threaddata.c[1].x, posctl_threaddata.c[1].y);
// printf ("%s:%d posctl_threaddata.a1: %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_threaddata.a1[0].x, posctl_threaddata.a1[0].y,
// posctl_threaddata.a1[1].x, posctl_threaddata.a1[1].y);
// printf ("%s:%d posctl_threaddata.a2: %d \t %d -> \t %d \t %d\n", __FILE__, __LINE__,
// posctl_threaddata.a2[0].x, posctl_threaddata.a2[0].y,
// posctl_threaddata.a2[1].x, posctl_threaddata.a2[1].y);
if (posctl_threaddata.c[0].x != -1 && posctl_threaddata.c[0].y != -1 &&
posctl_threaddata.c[1].x != -1 && posctl_threaddata.c[1].y != -1) {
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, S_X(posctl_calib_debug.c[0].x), S_Y(posctl_calib_debug.c[0].y));
cairo_line_to(cr, S_X(posctl_calib_debug.c[1].x), S_Y(posctl_calib_debug.c[1].y));
cairo_move_to(cr, S_X(posctl_threaddata.c[0].x), S_Y(posctl_threaddata.c[0].y));
cairo_line_to(cr, S_X(posctl_threaddata.c[1].x), S_Y(posctl_threaddata.c[1].y));
cairo_stroke(cr);
}
if (posctl_calib_debug.a1[0].x != -1 && posctl_calib_debug.a1[0].y != -1 &&
posctl_calib_debug.a1[1].x != -1 && posctl_calib_debug.a1[1].y != -1) {
if (posctl_threaddata.a1[0].x != -1 && posctl_threaddata.a1[0].y != -1 &&
posctl_threaddata.a1[1].x != -1 && posctl_threaddata.a1[1].y != -1) {
cairo_set_source_rgb(cr, 1.0, 0.5, 1.0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, S_X(posctl_calib_debug.a1[0].x), S_Y(posctl_calib_debug.a1[0].y));
cairo_line_to(cr, S_X(posctl_calib_debug.a1[1].x), S_Y(posctl_calib_debug.a1[1].y));
cairo_move_to(cr, S_X(posctl_threaddata.a1[0].x), S_Y(posctl_threaddata.a1[0].y));
cairo_line_to(cr, S_X(posctl_threaddata.a1[1].x), S_Y(posctl_threaddata.a1[1].y));
cairo_stroke(cr);
}
if (posctl_calib_debug.a2[0].x != -1 && posctl_calib_debug.a2[0].y != -1 &&
posctl_calib_debug.a2[1].x != -1 && posctl_calib_debug.a2[1].y != -1) {
if (posctl_threaddata.a2[0].x != -1 && posctl_threaddata.a2[0].y != -1 &&
posctl_threaddata.a2[1].x != -1 && posctl_threaddata.a2[1].y != -1) {
cairo_set_source_rgb(cr, 1.0, 0.5, 1.0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, S_X(posctl_calib_debug.a2[0].x), S_Y(posctl_calib_debug.a2[0].y));
cairo_line_to(cr, S_X(posctl_calib_debug.a2[1].x), S_Y(posctl_calib_debug.a2[1].y));
cairo_move_to(cr, S_X(posctl_threaddata.a2[0].x), S_Y(posctl_threaddata.a2[0].y));
cairo_line_to(cr, S_X(posctl_threaddata.a2[1].x), S_Y(posctl_threaddata.a2[1].y));
cairo_stroke(cr);
}
}

@ -227,12 +227,14 @@ void Simulation::Reset() {
axis[i % 2].defAngle = 180.0 + dAngle + (10.0 * (double)rand() / ((double) RAND_MAX)) - 5.0;
axis[i % 2].defLen = dLen + ((dLen/2.0) * (double)rand() / ((double) RAND_MAX) - (dLen/4.0));
axis[i % 2].v = 1.0;
axis[i % 2].vdest = 1.0;
axis[i % 2].active = 1;
i++;
axis[i % 2].defAngle = 180.0 + dAngle + (10.0 * (double)rand() / ((double) RAND_MAX)) + 85.0;
axis[i % 2].defLen = dLen + ((dLen/2.0) * (double)rand() / ((double) RAND_MAX) - (dLen/4.0));
axis[i % 2].v = 1.0;
axis[i % 2].vdest = 1.0;
axis[i % 2].active = 1;
// normalize angle between 0..360°
@ -309,6 +311,12 @@ void Simulation::ThreadProcess() {
if (posX > w) posX = 0.0;
if (posY > h) posY = 0.0;
for (int i = 0; i < 2; i++) {
axis[i].v = axis[i].v * (1.0-SIMULATION_MOTORSPEEDUP) + axis[i].vdest * SIMULATION_MOTORSPEEDUP;
}
// printf ("%s:%d axis %f (%f) %f (%f)\n", __FILE__, __LINE__, axis[0].v, axis[0].vdest, axis[1].v, axis[1].vdest);
#ifdef DEBUG_POSCTL
debug_tofile((char*)"simulation.log", 0, (char*)"%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g\n",
dAngle, dLen, x, y, dx[0], dy[0], ms,
@ -347,13 +355,15 @@ void Simulation::SetResolution (int w, int h) {
void Simulation::AxisSetValue (int a, double v) {
// printf ("%s:%d %s Axis:%d Value:%f\n", __FILE__, __LINE__, __FUNCTION__, a, v);
if (a < 0 || a > 1) return;
axis[a].v = v;
axis[a].vdest = v;
axis[a].active = 1;
}
void Simulation::AxisStop() {
// printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
axis[0].vdest = axis[0].v = 0.0;
axis[1].vdest = axis[1].v = 0.0;
axis[0].active = 0;
axis[1].active = 0;
}

@ -26,9 +26,10 @@
#include "gui.h"
#include "videodev.h"
#define SIMULATION_MOTORSPEEDUP 0.01
struct SimAxisCtl {
int active;
double vdest;
double v;
double defLen;
double defAngle;

Loading…
Cancel
Save