48 sprintf(DXL.
buftx,
"8%02X", motor);
55 }
while(DXL.
bufrx[0] ==
'0' && DXL.
bufrx[1] ==
'0' && er == 0 && ns != 0);
70 sprintf(DXL.
buftx,
"1%02X", motor);
76 sscanf(buf,
"%lx", &ns);
87 ch = (str[0] -
'0') << 4;
89 ch = (str[0] -
'0' - 7) << 4;
93 ch += str[1] -
'0' - 7;
111 char str[80], buf[80], *s;
113 unsigned long stbyte = 0;
119 sprintf(DXL.
buftx,
"/");
127 sprintf(str,
"0x%s",buf);
128 stbyte = strtol(str, &s, 16);
199 unsigned long stbyte = 0;
209 sprintf(DXL.
buftx,
"/");
216 if(er)
Message(
"Serial Error!", er);
334 sprintf(DXL.
buftx,
"&%02X%02X", 0, 0);
340 sprintf(DXL.
buftx,
"&%02X%02X", powa, powb);
358 sprintf(DXL.
buftx,
"'%02X%02X", stepa, stepb);
377 sprintf(DXL.
buftx,
"(%02X%02X", slopea, slopeb);
395 sprintf(DXL.
buftx,
"4%02X%02X", speeda, speedb);
404 int AMS_TrackOn(
int id,
int adir,
int bdir,
unsigned long acount,
unsigned long bcount)
412 sprintf(DXL.
buftx,
"0%02X%08lX%02X%08lX", adir, acount, bdir, bcount);
430 sprintf(DXL.
buftx,
"5%02X%02X", amot, bmot);
447 sprintf(DXL.
buftx,
"3%02X", mtr);
466 sprintf(DXL.
buftx,
"-%02X%02X", dira, dirb);
502 sprintf(DXL.
buftx,
"6%08X%08X", (
unsigned int)on, (
unsigned int)off );
513 int AMS_sendstep(
int id,
int dira,
int dirb,
unsigned long stepa,
unsigned long stepb)
522 sprintf(DXL.
buftx,
".%02X%08lX%02X%08lX", dira, stepa, dirb, stepb);
539 sprintf(DXL.
buftx,
"*%02X%02X%02X%02X", homea, worka, homeb, workb);
558 sprintf(DXL.
buftx,
"+%02X%02X", mota, motb);
576 sprintf(DXL.
buftx,
"<%02X%02X", mota, motb);
594 sprintf(DXL.
buftx,
"7", 1);
609 unsigned long st, et, x;
630 D_VRange(NULL, (
long) x * 100 / tout, 255, 0, 0 );
631 tl = (long) ((
double)fabs(((
double)(labs(et - st) - tout))/1000.0 ));
632 sprintf(buf,
"%.1lf sec. left", (
double)fabs(((
double)(labs(et - st) - tout))/1000.0 ));
638 }
while(labs(et - st) < tout);
644 int AMS_DoPos(
int id,
int dira,
int dirb,
unsigned long stepa,
unsigned long stepb)
675 D_VRange(
"Positioning Mirror",0, 255, 0, 0);
678 D_VRange(
"Positioning Grating",0, 255, 255, 0);
681 D_VRange(
"Positioning Filter Wheel",0, 0, 0, 255);
684 D_VRange(
"Positioning ND Filter Wheel",0, 192, 0, 255);
687 D_VRange(
"Positioning Zenith",0, 0, 255, 255);
690 D_VRange(
"Positioning Azimuth",0, 0, 192, 255);
779 sprintf(buf,
"Steps A: %ld", ns);
786 sprintf(buf,
"Steps B: %ld", ns);
798 sprintf(buf,
"Steps A: %ld", stepa);
805 sprintf(buf,
"Steps B: %ld", stepb);
822 int c = motor, d = 0;
830 sprintf(buf,
"%s",
"Positioning");
835 if(er) {
Message(
"n Step not sent! 1", er);
break; }
840 sprintf(buf,
"%s",
"Positioning");
845 if(er) {
Message(
"n Step not sent! 2", er);
break; }
850 sprintf(buf,
"%s",
"Positioning");
856 if(er) {
Message(
"n Step not sent! 2", er);
break; }
862 sprintf(buf,
"%s",
"Positioning");
868 if(er) {
Message(
"n Step not sent! 2", er);
break; }
875 sprintf(buf,
"%s",
"Positioning");
883 Message(
"n Step not sent! 3", er);
890 sprintf(buf,
"%s",
"Positioning");
896 if(er) {
Message(
"n Step not sent! 4", er);
break; }
919 sprintf(DXL.
buftx,
"9%02X", w);
938 sprintf(DXL.
buftx,
"2%02X%02X", mtr1, mtr2);
956 sprintf(DXL.
buftx,
">%08lX%08lX", par1, par2);
975 sprintf(DXL.
buftx,
";%02X%02X", eslopea, eslopeb);
999 if(er)
Message(
"Serial Error!", er);
1003 sprintf(buf,
"A Proxy, Home = %d, Work = %d\nB Proxy, Home = %d, Work = %d\nAll bits = %02XH, %d%d%d%d%d%d%d%d bin",
1004 (a >> 3) & 1, (a >> 2) & 1, (a >> 1) & 1, a & 1, a,
1005 (a >> 7) & 1,(a >> 6) & 1, (a >> 5) & 1, (a >> 4) & 1,(a >> 3) & 1, (a >> 2) & 1, (a >> 1) & 1, a & 1 );
1023 sprintf(DXL.
buftx,
":%02X", ch );
1051 sprintf(DXL.
buftx,
"G%02X", par1);
1055 d = atoi(DXL.
bufrx);
1074 sprintf(DXL.
buftx,
"H%02X", par1);
1090 sprintf(buf,
"DEBUG: AMS%d, Err = %d", DXL.
add+1, er);
1099 sprintf(buf,
"Txed: %s", DXL.
buftx);
1104 sprintf(buf,
"Rxed: %s", DXL.
bufrx);
1119 while((
unsigned long)labs(e - s) < d);
1142 unsigned char ch = val;
1143 if(ch <= 9) ch +=
'0';
1155 unsigned char cksm = 0,
ch;
1166 for(c = 0; c < len; c++)
1189 unsigned char cksm = 0, rcksm, add;
1195 st = GetTickCount();
1199 et = GetTickCount();
1201 }
while(c < *len && labs(et - st) < 500);
1206 while(DXL.
bufrx[p++] !=
'$' && p < 80);
1216 cksm += DXL.
bufrx[p + 1];
1217 cksm += DXL.
bufrx[p + 2];
1218 for(c = p + 3; c < 80; c++)
1220 if(DXL.
bufrx[c] !=
'#')
1222 cksm += DXL.
bufrx[c];
1223 rx[c - 3] = DXL.
bufrx[c];
int AMS_Divisore(int id, unsigned long par1, unsigned long par2)
stepm StepM
Stepper motors parameters structure.
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
int AMS_TestWork(int id, int par1)
verify the if work position has been reached
gui Gui
Graphic User Interface Structure.
NoMangle int DLL_IMPORT_EXPORT SioGets(int, LPSTR, unsigned)
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
unsigned char DXL_HexBin(char *str)
int AMS_Slope(int id, int slopea, int slopeb)
Set slope to the Stepper motors Procedure for setting the slope fot the Stepper Motors.
short DB_FG_Plbl[3]
Foreground PASSIVE Label Colors.
void MLoopWhileEvents(int discard)
void writelogmotor(int mod, int id_motore, int k, int d, long steps, unsigned char ams_id)
Write Motor Operations on Log File. Write on the SM.LOG file the commands send to the motors...
optionini DOption
Options for DAS execution.
char buftx[1024]
Tx buffer.
void MShellRealize(MOBJECT obj)
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
int AMS_TrackOn(int id, int adir, int bdir, unsigned long acount, unsigned long bcount)
Activate tracking Procedure for Stepper Motor tracking activation.
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
int AMS_Home(int id, int mota, int motb)
Home position for the selected motor the home position is reached with the standard parameters (1KHz...
DXL structure. Structure for the serial communication with the AMS adapter.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
das structure (contain all the previous structures) .
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
#define TESTSZAMODE
execution driven by SZAPRG file
MOBJECT MCreateLabel(MOBJECT parent, const char *text, MTFont font)
flag Flag
Structure for different flags.
int AMS_firmrev(int id)
Firmware Revision Number .
#define DBDEMO
execution in demo mode
int AMS_Step(int id, int stepa, int stepb)
Set stepping for the Stepper motors Procedure for setting steps for the Stepper Motors.
void AMS_PWM(int id, int on, int off)
set the on/off time on the PWM set the on/off time on the PWM.
void AMS_Default(int id)
Set default values to AMS parameters Procedure for setting the default values of power.speed, stepping and slope to the selected AMS adapter.
NoMangle int DLL_IMPORT_EXPORT SioDone(int)
void MObjectSetText(MOBJECT obj, const char *text)
int FlgSM_Stop
Steppers Motor Activity: 0 = Motors moving; 1 = Motors stopped.
NoMangle int DLL_IMPORT_EXPORT SioReset(int, int, int)
int AMS_TestHome(int id, int par1)
verify if the home position has been reached
char bufrx[1024]
Rx buffer.
int add
Peripheral address.
int AMS_chkbitsts_old(int id, int bitn)
unsigned char DXL_ByteHex(unsigned char val)
int AMS_HomeDefault(int id, int mota, int motb)
long postime[AMSMAX][2]
time necessary for positioning
int AMS_MotorOn_Off(int id, int mtr1, int mtr2)
Motor ON-OFF. Switch On-Off the selected motor of the selected AMS.
int DXL_Close(void)
Close COM.
void Status(char *tit)
Writes information's on the Status label .
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
int AMS_ReadAD(int id, int ch)
int AMS_Power(int id, int powa, int powb)
Set Power for AMS Procedure for setting the user choosed power to the selected AMS adapter...
int AMS_ESlope(int id, int eslopea, int eslopeb)
short DB_BG_Plbl[3]
Background PASSIVE Label Colors.
NoMangle int DLL_IMPORT_EXPORT SioPutc(int, char)
unsigned long AMS_ReadStep(int id, int motor)
read performed steps Procedure for the determination of the number of steps executed.
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
MOBJECT MCreateShell(const char *title, int flags)
NoMangle int DLL_IMPORT_EXPORT SioParms(int, int, int, int)
int DXL_Open(int addr, int com, int baud)
Open COM.
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
int AMS_Speed(int id, int speeda, int speedb)
Set speed to the Stepper motors Procedure for setting speed for the Stepper Motors.
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
void MLabelSetAlignment(MOBJECT p, int align)
controlpanel ContrPanel
Control Panel Structure.
int AMS_TrackOff(int id, int amot, int bmot)
tracking off Procedure for Stepper Motor tracking de-activation
int AMS_AzzeraCoord(int id, int mtr)
Set to zero the number of steps on the selected motor Set to zero the number of steps on the selecte...
#define AMS1
AMS1 address.
int AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
NoMangle int DLL_IMPORT_EXPORT SioRxQue(int)
void D_Positioning(MOBJECT p, int id, long tout)
Callback for the void D_VRange and display also the status in the corresponding CP labels...
int AMS_SetPolarity(int id, int homea, int worka, int homeb, int workb)
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
void AMS_assadd(int w)
Assign AMS address Procedure for assigment of the AMS address.
void DXL_TxByte(unsigned char v)
NoMangle int DLL_IMPORT_EXPORT SioBaud(int, unsigned)
int com
Comunication port.
void MObjectSetForegroundRGB(MOBJECT obj, int r, int g, int b)
int AMS_sendstep(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Send steps Procedure for sending steps to the Stepper Motor.
int on
PRG execution control variabile.
int AMS_DoPos(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Execute Positioning Execute Stepper positioning. Make all the control on the status of the selected m...
void DXL_TxStr(char *tx, int len)
send string to a serial port
int AMS_TestPos(int id, int motor)
Test positioning status Procedure for testing the positioning status of the selected motor...
int exemode
Set the Execution MODE (Execution modes)
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .