Skip to content

Commit

Permalink
Create a full mirror of a given workplan and append it to the origina…
Browse files Browse the repository at this point in the history
…l STPNC

project. Uses MT connect data for feeds and stpnc file to fill in rapid paths
  • Loading branch information
salamb committed Jan 20, 2016
1 parent 9019efd commit aae7402
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
40 changes: 29 additions & 11 deletions Patcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ void Patcher::patchRapid(List<long long>^ pathList,STEPNCLib::AptStepMaker ^ apt
apt->Workingstep("starting Feed");
}


void Patcher::debugOut(STEPNCLib::AptStepMaker^apt, STEPNCLib::Finder^ find,double feed) {

Console::WriteLine("feed {0}", feed);

}

//given a stpnc file and a workplan within the stepnc file
// append a workplan with tool paths genereated from the xml data
//that contains tool position
Expand All @@ -475,7 +482,7 @@ void Patcher::patchRapid(List<long long>^ pathList,STEPNCLib::AptStepMaker ^ apt
void Patcher::appendPatchWorkPlan(String^partFile,String^coorFile,String^outName,String^ path,bool toInches ){
Console::WriteLine("input \n part {0}\n xml file{1} \n path to desired workplan {2}",partFile,coorFile,path);
//assume all units are inches or inches per sec
double max_feed=.8;//inches per sec
double max_feed=.3;//inches per sec
//get path position coordinates from the xml file with delta t in seconds at end


Expand Down Expand Up @@ -524,18 +531,19 @@ void Patcher::appendPatchWorkPlan(String^partFile,String^coorFile,String^outName
String ^str;
array<double>^ coor1;
array<double>^coor2;

bool startRapid=false;
bool currentCoorisRapid=true;
int currentTransition=0;
__int64 debugStep;
//Console::WriteLine("number of path coordinates {0}",coorList->Count);
//Console::WriteLine("number of transitions {0}",transitionPaths->Count);
//determine if starting position is in rapid mode or feed
if(sample->getSize()>1){
coor1 = sample->getCoor(0);
coor2= sample->getCoor(1);

if (actualFeedRate(coor1,coor2)>max_feed){
if (actualFeedRate(coor1, coor2)>max_feed){
currentCoorisRapid=true;


Expand All @@ -547,6 +555,8 @@ void Patcher::appendPatchWorkPlan(String^partFile,String^coorFile,String^outName
if(currentCoorisRapid){
apt->Rapid();
}else{


apt->Feedrate(max_feed);
}
}
Expand Down Expand Up @@ -578,7 +588,14 @@ void Patcher::appendPatchWorkPlan(String^partFile,String^coorFile,String^outName
}

}else if(currentCoorisRapid==false){

debugStep = apt->GetCurrentWorkingstep();
if (find->GetWorkingstepName2(debugStep)->Contains("WS 24")) {
Console::WriteLine("WS {0}", find->GetWorkingstepName2(debugStep));
debugOut(apt, find, actualFeed);

}


startRapid=false;
apt->GoToXYZ("feed",coor2[0],coor2[1],coor2[2]);
}
Expand Down Expand Up @@ -744,13 +761,13 @@ void Patcher::createPatchedFile(String^ partFile,String^ WPpath,String^newFileNa



if (!prevCoorIsRapid) {
if (!prevCoorIsRapid&&isFeedState(pastRapids,3)) {

apt->Feedrate(currentTP->getWS()->getMaxFeed());

apt->SpindleSpeed(currentTP->getWS()->getMaxSpindle());
apt->GoToXYZ("feed", coor2[0], coor2[1], coor2[2]);
}else if(prevCoorIsRapid&&!pastRapids[pastRapids->Count-2]) {
}else if(rapidStarted(pastRapids)) {

currentTP = patchRapidToolPaths(apt, find, currentTP);

Expand Down Expand Up @@ -847,15 +864,15 @@ ToolPath ^tp2 = nullptr;
Console::WriteLine(" Transitioned to a new WS without rapiding");
}
}

/*
if (tp1->getWS()->getIndex() >= 9) {
apt->Workingstep("Rapiding");
}
}*/
List<__int64> ^temp = gcnew List<__int64>();
temp->Add(tp1->getId());
List<double> ^loc = getAllPoints(temp, find);
Console::WriteLine("rapid starting at WS {0} index {1} coor {2} {3} {4}", tp1->getWS()->getName(), tp1->getIndex(), loc[0], loc[1], loc[2]);
//Console::WriteLine("rapid starting at WS {0} index {1} coor {2} {3} {4}", tp1->getWS()->getName(), tp1->getIndex(), loc[0], loc[1], loc[2]);
while (tp1->rapid())
{
STPNCpath->Add(tp1->getId());
Expand All @@ -878,11 +895,12 @@ ToolPath ^tp2 = nullptr;
}
tp1 = tp2;
}
/*
if (tp1->getWS()->getIndex() >= 9) {
apt->Workingstep("Feed");
}

*/
return tp1;
}
/*
Expand Down
1 change: 1 addition & 0 deletions Patcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ ref class Patcher{
void rapidToPoints(STEPNCLib::AptStepMaker^apt, STEPNCLib::Finder ^ find, List<__int64>^STPNCpath);
bool rapidStarted(List<bool>^ state);
bool isFeedState(List<bool>^state, int count);
void debugOut(STEPNCLib::AptStepMaker^apt, STEPNCLib::Finder^ find,double feed);
};
#endif
4 changes: 2 additions & 2 deletions stepnc_hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ int main(int argc, char * argv[])
//appendToFile("sample_300ms.xml","hardmoldy_ext.stpnc","moldy_300.stpnc",true);
//appendPatchWorkPlan("hardmoldy_ext.stpnc","sample_300ms.xml","patched_300.stpnc","HARDMOLDY/Profiling/Boeing",true);

//pat->createPatchedFile("hardmoldy_imts_signed.stpnc", "HARDMOLDY", "patchedMoldy", "PatchWP", "Data.txt");
pat->createPatchedFile("hardmoldy_imts_signed.stpnc", "HARDMOLDY", "patchedMoldy", "PatchWP", "Data.txt");
//pat->appendToFile("Data.txt", "hardmoldy_imts_signed.stpnc", "patchedMoldy", true);
pat->appendPatchWorkPlan("hardmoldy_imts_signed.stpnc", "Data.txt", "moldySeperated", "HARDMOLDY/Profiling/Boeing", true);
//pat->appendPatchWorkPlan("hardmoldy_imts_signed.stpnc", "Data.txt", "moldySeperated", "HARDMOLDY/Profiling/Boeing", true);
Console::WriteLine("done");
String ^readIn =Console::ReadLine();
return 0;
Expand Down

0 comments on commit aae7402

Please sign in to comment.