Hello Guest it is April 25, 2024, 08:24:34 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Scoppio

Pages: 1
1
Hello people,

I've started a project sometime ago and now its almost finished... "almost" because it was developed under vista and seven, but the final plataform is Windows XP

Today I tested it for the first time in the computer it will receive the program and for my surprise it didn't worked.

After some time crushing the head against the wall I realised the problem, when I call this specific and yet most important part of the code about the COM with the MACH4 the program was'nt answering:

                Mach = (Mach4.IMach4)Marshal.GetActiveObject("Mach4.Document");
                Script = (Mach4.IMyScriptObject)Mach.GetScriptDispatch();

Actually, it was... it was saying that I could not handle an HResult from this COM, but I can't even start to understand why, for real, the program/plugin works automatizing the Mach3 (entirely constructed in c#), but when I try to start a connection with the program so I can send the Script.Code( ) or any other procedure/parametre it get stuck in this ******Mach = (Mach4.IMach4)Marshal.GetActiveObject("Mach4.Document");********

Have anyone ever passed by this kind of problem? I just can't realize why this would happen. I even tried to compile the program inside the XP but it didn't worked as well.

Thanks in advance
Lucas S.Coppio

2
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?

Pages: 1