Hello Guest it is March 28, 2024, 03:35:00 PM

Author Topic: Plugin problems with Mach3 functions  (Read 4329 times)

0 Members and 1 Guest are viewing this topic.

Plugin problems with Mach3 functions
« on: December 01, 2010, 08:34:28 AM »
Hello you all, I'm developing a plugin that reads a mySql table, convert it to a G code and then it should load it in Mach 3 and start the cycle.

At this very moment I'm trying to use the functions to load the code and then run it, but the Mach3 keeps sending errors and I don't understand why it gives such errors.

Here is an example of what is happening:

Code: [Select]
private: System::Void iniciarButton_Click(System::Object^  sender, System::EventArgs^  e) {

String^ selectedNorma = (String^)(this->normaComboBox->SelectedItem);
string text[5], outputGcode[1024];
int pseudoId = this->normaComboBox->SelectedIndex;
string tempText[5];
char *stochar, *charToAng, *gCode, *gCodeTemp;
float angA = 0.0, angB = 0.0;
string commA, commB; //, gCodeTemp;
int minCDi, maxCDi, ordemi[80], indexOfString, lastOrder = 0;
gCodeTemp = (char*) malloc(sizeof(char)*128);
int comm1;
myDatabase conexao("*******", "*******", "*****", "*****", "norma");
int numf = conexao.search("norma", "id", "name");
int idFinal = conexao.stringAnswer( pseudoId, 0);
string descricao = conexao.searchDesc(idFinal);
this->descricaoDaNormaTextBox->Text = convertion( descricao);
int numberOfRows = conexao.searchAngulos("angulos", idFinal, 0);

if( this->fotometro25MRadioButton->Checked == 1){
comm1 = 4;
}else{
comm1 = 3;
}


int tempoDeInicio = atoi(convertion(this->aquecimentoInicialTextBox->Text));
int tempoDeAquecimento = atoi(convertion(this->aquecimentoTextBox->Text));

tempoDeInicio *= 60;
tempoDeAquecimento *= 60;

for( int i = 0, k = 0, j = 0; i < 80; i++){

text[k] = conexao.stringAnswer( j++); //anguloA

if( !text[k].empty()){

tempText[k] = text[k];
stochar = (char*) text[k].c_str();

if( (indexOfString = text[k].find_first_of( 'D', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commA = "D";
}else if( (indexOfString = text[k].find_first_of( 'U', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commA = "U";
}else if( (indexOfString = text[k].find_first_of( 'R', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commA = "R";
}else if( (indexOfString = text[k].find_first_of( 'L', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commA = "L";
}

angA = atof((char*) text[k].c_str());

switch( commA.at(0)){
case 'U':
commA = "A";
break;
case 'D':
commA = "A";
angA *= -1.0;
break;
case 'R':
commA = "B";
break;
case 'L':
commA = "B";
angA *= -1.0;
break;
}
}
k++;

text[k] = conexao.stringAnswer( j++); //anguloB
if( !text[k].empty()){

tempText[k] = text[k];
stochar = (char*) text[k].c_str();

if( (indexOfString = text[k].find_first_of( 'D', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commB = "D";
}else if( (indexOfString = text[k].find_first_of( 'U', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commB = "U";
}else if( (indexOfString = text[k].find_first_of( 'R', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commB = "R";
}else if( (indexOfString = text[k].find_first_of( 'L', 0)) >= 0 ){
tempText[k].erase( indexOfString, 1);
commB = "L";
}

angB = atof((char*) text[k].c_str());

switch( commB.at(0)){
case 'U':
commB = "A";
break;
case 'D':
commB = "A";
angB *= -1.0;
break;
case 'R':
commB = "B";
break;
case 'L':
commB = "B";
angB *= -1.0;
break;
}
}
k++;

text[k] = conexao.stringAnswer( j++);//ordem
if( !text[k].empty()){
stochar = (char*) text[k].c_str();
ordemi[i] = atoi(stochar);
if(lastOrder < ordemi[i])
lastOrder = ordemi[i];
}else{

//sprintf( gCodeTemp, "%i", lastOrder);
//outputGcode[1023] = (string) gCodeTemp;
break;
}
k = 0;
strcpy( gCodeTemp, "");
sprintf( gCodeTemp, "G01 %c%.2f %c%.2f", commA.at(0), angA, commB.at(0), angB);
outputGcode[ordemi[i]] = (string) gCodeTemp;
}

ofstream saveFile;
char data[1024];
this->tempoDeParada = atoi(convertion(this->tempoDePausaTextBox->Text));

saveFile.open( "code.g");
saveFile << ";(Medição - lâmpada fria)";
saveFile << "G0 A0 B0          (posiciona no eixo 0)\n";
saveFile << "G4 P" << tempoDeInicio << "          (tempo de preaquecimento)\n";
for(int j = 0; j < lastOrder; j++ ){
saveFile << outputGcode[ordemi[j]] << "          (posiciona os eixos A e B)\n";
saveFile << "G4 P" << tempoDeParada <<  "          (tempo de espera antes da medição)\n";
saveFile << "M" << comm1 << "          (aciona leitura de medição, M3 = comm1, M4 = comm2)\n";
}
saveFile << "G0 A0 B0          (posiciona no eixo 0)\n";
saveFile << ";(Medição - lâmpada quente)\n";
saveFile << "G4 P" << tempoDeAquecimento <<  "          (tempo de aquecimento para medição nova)\n";

for(int j = 0; j < lastOrder; j++ ){
saveFile << outputGcode[ordemi[j]] << "          (posiciona os eixos A e B)\n";
saveFile << "G4 P" << tempoDeParada <<  "          (tempo de espera antes da medição)\n";
saveFile << "M" << comm1 << "          (aciona leitura de medição)\n";
}
saveFile << "G0 A0 B0          (posiciona no eixo 0)\n";
saveFile.close();
free( gCodeTemp);


}

This is the function where the gCode is read and then save in the file "code.g", it works perfectly (sorry for the portuguese and english all mixed up, but thats not the point).

Then I tried adding THIS to the end of the code, right below the "free gCodeTemp".

Mach->LoadGCodeFile( "E\\Mach3\\code.g");
Script->DoButton( CYCLE_START);

First thing that happened - CYCLE_START is undeclared... ok, I haven't declared it yet, but no tutorial tells me which is the number of the CycleStart Button...

Then to try the Mach->LoadGCodeFile I comented the "Script" and start to debug it...
Mach3 then opens, I open the Plugin Configuration, then I open the converter function and it sends an error window:

Code: [Select]
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll

Additional information: Was not possible to load file of assembly 'Interop.Mach4.1.0, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencys. The system could not find the specified file.

Some one knows what to do with it?
Re: Plugin problems with Mach3 functions
« Reply #1 on: December 03, 2010, 06:31:00 AM »
looks like the program cannot find the interop.Mach4.1.0.dll, anyone knows how to solve it? please... :(