Code:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#pragma hdrstop
//---------------------------------------------------------------------------
// Wichtiger Hinweis zur DLL-Speicherverwaltung, wenn Ihre DLL die
// statische Version der Laufzeitbibliothek verwendet:
//
// Wenn Ihre DLL Funktionen exportiert, die String-Objekte (oder struct/class,
// die verschachtelte Strings enthalten) als Parameter oder Funktionsergebnisse übergeben,
// müssen Sie die Bibliothek MEMMGR.LIB zum DLL-Projekt und
// auch zu anderen Projekten, die diese DLL benutzen, hinzufügen. Sie müssen auch
// MEMMGR.LIB verwenden, wenn andere Projekte, die die DLL benutzen, new- oder delete-Operation auf
// Klassen durchführen, die nicht von TObject abstammen und von der DLL exportiert werden.
// Durch das Hinzufügen von MEMMGR.LIB werden die DLL und die aufrufenden EXEs
// dazu veranlasst, BORLNDMM.DLL als Speicher-Manager zu verwenden. In diesen Fällen
// muß die Datei BORLNDMM.DLL mit der DLL weitergegeben werden.
//
// Um die Verwendung von BORLNDMM.DLL zu vermeiden, sollten String-Informationen
// als "char *" oder ShortString übergeben werden.
//
// Wenn Ihre DLL die dynamische Version der RTL verwendet, müssen Sie
// MEMMGR.LIB nicht explizit hinzufügen, da dies implizit geschieht.
//---------------------------------------------------------------------------
//------------------------------------------------ ---------------------------
// Important Note on the DLL memory management, if your DLL the
// Static version of the run-time library:
//
// If your DLL functions exported, the string objects (or struct / class,
// Nested strings) as a parameter or functional results over
// You must MEMMGR.LIB to the library project and DLL
// Also to other projects that use this DLL, adding. They must also
// MEMMGR.LIB, if other projects that use the DLL, new or delete operation to
// Classes that are not descended from TObject and DLL exported.
// By adding MEMMGR.LIB the DLL and the calling EXEs
// Led BORLNDMM.DLL as storage managers to use. In these cases
// BORLNDMM.DLL the file with the DLL parties.
//
// To the use of BORLNDMM.DLL to avoid information should String
// As "char *" or short string.
//
// If your DLL dynamic version of the RTL, you need to
// MEMMGR.LIB not explicitly add, as this is done implicitly.
//------------------------------------------------ ---------------------------
USEFORM("main.cpp", Form1);
USEUNIT("sioce_bl.cpp");
USEFORM("checkpassword.cpp", PasswordDlg);
USEFORM("inputdata.cpp", input_data_Dlg);
USEFORM("explore.cpp", exploreDlg);
USERES("tool_dll.res");
USEFORM("scrollbox.cpp", Form_scrollbox_dialog);
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}
//---------------------------------------------------------------------------
#define BUILD_DLL
#include <stdio.h>
#include <math.h>
#include "tool_dll.h"
#include "main.h"
#include "checkpassword.h"
#include "inputdata.h"
#include "explore.h"
#include "sioce_bl.h"
#include "scrollbox.h"
#include <Registry.hpp>
//---------------------------------------------------------------------------
void gsp_getcounter(int adresse, char* data);
void gsp_getstatus(int adresse, char* data);
void gsp_move_relativ(int adresse, char* data_in, char *data_out);
void gsp_move_absolut(int adresse, char* data_in, char *data_out);
void gsp_init_negativ(int adresse, char *data_out);
void gsp_init_positiv(int adresse, char *data_out);
bool read_registry(int adresse);
void read_registry_achsenparameter(void);
//---------------------------------------------------------------------------
sioce sio_gsp;
int axis_type;
int run_frequence;
int ramp_frequence;
int hr_frequence;
int run_current;
int stop_current;
int gear_factor;
int gear_factoren[5];
TRegistry *ptr_Registry;
//---------------------------------------------------------------------------
#define QUICKLFOW_TOOLDLL_X_ACHSE_REGKEY "\\software\\quickflow\\tooldll\\x_axis"
#define QUICKLFOW_TOOLDLL_Y_ACHSE_REGKEY "\\software\\quickflow\\tooldll\\y_axis"
#define QUICKLFOW_TOOLDLL_Z_ACHSE_REGKEY "\\software\\quickflow\\tooldll\\z_axis"
#define QUICKLFOW_TOOLDLL_W_ACHSE_REGKEY "\\software\\quickflow\\tooldll\\w_axis"
#define QUICKLFOW_TOOLDLL_C_ACHSE_REGKEY "\\software\\quickflow\\tooldll\\c_axis"
#define AXIS_TYPE "Axis_Type"
#define RUN_FREQUENCE "Run_Frequence"
#define RAMP_FREQUENCE "Ramp_Frequence"
#define HR_FREQUENCE "HR_Frequence"
#define GEAR_FACTOR "Gear_Factor"
#define RUN_CURRENT "Run_Current"
#define STOP_CURRENT "Stop_Current"
//---------------------------------------------------------------------------
extern "C" DLL_EXP void UPPERCASE(char* data_in, char *data_out)
{
wsprintf(data_out,"%s",StrUpper(data_in));
}
//---------------------------------------------------------------------------
extern "C" DLL_EXP void LOWERCASE(char* data_in, char *data_out)
{
wsprintf(data_out,"%s",StrLower(data_in));
}
//---------------------------------------------------------------------------
extern "C" DLL_EXP void DEZ_TO_HEX(char* data_in, char *data_out)
{
sprintf(data_out,"%lX",atol(data_in));
}
//---------------------------------------------------------------------------
extern "C" DLL_EXP void HEX_TO_DEZ(char* data_in, char *data_out)
{
int i;
unsigned char l,h;
char hex_string[1024];
unsigned char ziel[256];
int len;
long int wert;
int potenz_zahl;
len = strlen(data_in);
if(len%2 != 0)
{
wsprintf(hex_string,"0%s",data_in);
}
else
{
wsprintf(hex_string,"%s",data_in);
}
len = strlen(hex_string);
for(i=0;i<len;i+=2)
{
h = (unsigned char)toupper(hex_string[i]);
l = (unsigned char)toupper(hex_string[i+1]);
if(isdigit(h))
{
h = (h-48) << 4;
}
else
{
if(isxdigit(h))
{
h = (h-55) << 4;
}
}
if(isdigit(l))
{
l = (l-48);
}
else
{
if(isxdigit(l))
{
l = (l-55);
}
}
ziel[i/2] = h | l;
}
wert = 0;
potenz_zahl = 0;
for(i=len/2;i>0;i--)
{
wert += ziel[i-1] * (long int)(pow(256,potenz_zahl));
potenz_zahl++;
}
wsprintf(data_out,"%ld",wert);
}
//---------------------------------------------------------------------------
extern "C" DLL_EXP void CUT_SPACES(char* data_in, char *data_out)
{
char text[256];
char *ptr_text;
wsprintf(text,"%s",data_in);
ptr_text = strchr(text,' ');
if(ptr_text)
{
*ptr_text = 0x00;
}
wsprintf(data_out,"%s",text);
}
//---------------------------------------------------------------------------
extern "C" DLL_EXP void STRING_LEN(char* data_in, char *data_out)
{
sprintf(data_out,"%ld",strlen(data_in));
}
//---------------------------------------------------------------------------
extern "C" DLL_EXP void CREATE_FAHZ(char* data_in, char *data_out)
{
double f_wert;
char text[256];
f_wert = atof(data_in);
memset(text,0x00,sizeof(text));
wsprintf(text,"FAHZ%06d",(int)(f_wert*100));
text[10] = 0x03;
wsprintf(data_out,"%s",text);
}
//---------------------------------------------------------------------------
Bookmarks