Skip to content

Commit

Permalink
debugging WP generation from STPNC file
Browse files Browse the repository at this point in the history
  • Loading branch information
salamb committed Jan 15, 2016
1 parent 538572a commit ec6b784
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 155 deletions.
3 changes: 3 additions & 0 deletions Exec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "Exec.h"
#include"stdafx.h"
WP^ Exec::getParent(){ return parent; };
11 changes: 6 additions & 5 deletions Exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ using namespace System::Text;
#ifndef __EXEC__
#define __EXEC__

ref class Exec
ref class WP;
ref class Exec
{
private:
String ^ name;
__int64 id;
__int64 index;
Exec^ parent;
WP^ parent;
bool typeWP;
public:

bool isWP(){return typeWP;};
bool isWP(){return typeWP;};
//get name of Executable
String^ getName(){return name;};
// get stpnc id of Executable
__int64 getId(){return id;};
// index in list of enabled executalbes for an enabled parent WorkPlan
__int64 getIndex(){return index;};

Exec^ getParent(){return parent;};
Exec(String^ n,__int64 ID,__int64 in,Exec^p,bool iswp){
WP^ getParent();
Exec(String^ n,__int64 ID,__int64 in,WP^p,bool iswp){
name=n;
id=ID;
index=in;
Expand Down
2 changes: 1 addition & 1 deletion MtConnector.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "MtConnector.h"


#include"stdafx.h"
MtConnector::MtConnector()
{
startedPush=false;
Expand Down
92 changes: 10 additions & 82 deletions Patcher.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Patcher.h"
#include"stdafx.h"
WP^ Patcher::getAllExec(__int64 root,STEPNCLib::Finder ^find,WP^plan,__int64 index){
WP^ mainWP =nullptr;
String^ name;
Expand Down Expand Up @@ -596,16 +597,18 @@ void Patcher::appendPatchWorkPlan(String^partFile,String^coorFile,String^outName
//force the apt builder and the find object to work in inches
void Patcher::OpenFile(String^file,String^ desiredWorkPlanPath,String^newWorkPlanName,STEPNCLib::Finder ^%find,STEPNCLib::AptStepMaker^%apt, __int64% wpID){

apt = gcnew STEPNCLib::AptStepMaker();
find=gcnew STEPNCLib::Finder();
// apt = gcnew STEPNCLib::AptStepMaker();
//find=gcnew STEPNCLib::Finder();
find->Open238(file);
apt->Open238(file);
array<String^>^ nameList=desiredWorkPlanPath->Split('/');
__int64 id= getWorkPlanByPath(nameList,find);
apt->Inches();
find->APIUnitsInch();
}
//Delete all workplans on directly nested under the main workplan
//except for wpid
void DeleteBefore(__int64 wpid,STEPNCLib::Finder ^find,STEPNCLib::AptStepMaker^apt){
void Patcher::DeleteBefore(__int64 wpid,STEPNCLib::Finder ^find,STEPNCLib::AptStepMaker^apt){
__int64 mainWP=find->GetMainWorkplan();
List<__int64> ^WPList=find->GetNestedExecutableAll(mainWP);
for (int i=0;i< WPList->Count;i++){
Expand All @@ -619,9 +622,10 @@ void DeleteBefore(__int64 wpid,STEPNCLib::Finder ^find,STEPNCLib::AptStepMaker^a

}

void Patcher::createPatchedFile(String^ partFile,String^ WPpath,String^newFileName,String^newWorkPlan,String^ coor,bool toInches){
STEPNCLib::AptStepMaker^ apt;
STEPNCLib::Finder^find;
void Patcher::createPatchedFile(String^ partFile,String^ WPpath,String^newFileName,String^newWorkPlan,String^ coor){
STEPNCLib::AptStepMaker^ apt = gcnew AptStepMaker();
STEPNCLib::Finder^find = gcnew Finder();

__int64 oldWPID;

OpenFile(partFile,WPpath,newWorkPlan,find,apt,oldWPID);
Expand All @@ -640,82 +644,6 @@ void Patcher::createPatchedFile(String^ partFile,String^ WPpath,String^newFileNa


/*
ToolPath^ nextPath(bool % newWP, bool% newWS){
ToolPath^temp=nextPath();
Exec^ tempExec;
if (temp!=nullptr){
newWP=false;
newWS=false;
return temp;
}
else{
WS^ tempWS=dynamic_cast<WS^>(parent);
ToolPath^ nextToolPath=nullptr;
List<WP^>^path=pathtoRoot(tempWS);
for (int i=0;i<path->Count;i++){
nextToolPath=recurseToNextToolPath(path[i],tempWS->getIndex());
}
}
}
List<WP^>^pathtoRoot(WS^temp){
List<WP^> ^path=gcnew List<WP^>();
WP^ temp1=dynamic_cast<WP^>(temp->getParent());
if(temp!=nullptr){
while (temp1!=nullptr){
path->Add(temp1);
temp1=dynamic_cast<WP^>(temp1->getParent());
}
}
return path;
}
ToolPath^ recurseToNextToolPath(WP^ current , __int64 startIndexAfter){
ToolPath^ result=nullptr;
for(int i=startIndexAfter+1;i<current->getExecutableCount();i++){
result =recurseToolPath(current->getExecutable(i));
if(result!=nullptr){
return result;
}
}
}
ToolPath^ recurseToolPath(Exec^ current){
WS^ tempWS=nullptr;
WP^ tempWP=nullptr;
WP^ tempWP2;
if (current->isWP()){
tempWP=dynamic_cast<WP^>(current);
}
else{
tempWS=dynamic_cast<WS^>(current);
}
if(tempWS!=nullptr){
if(tempWS->getPathCount()>0){
return tempWS->getPath(0);
}
}
if(tempWP!=nullptr){
for (int i=0;i<tempWP->getExecutableCount();i++){
return recurseToolPath(tempWP->getExecutable(i));
}
}
return nullptr;
}
*/

Expand Down
6 changes: 4 additions & 2 deletions Patcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ref class Patcher{
WP^ root;
String^ originalSTPNC;
String^newSTPNC;

public:
//open and init finder and apt obect file
//append a new workplan to the end of the workplans nested under the main work plan

Expand All @@ -48,7 +48,9 @@ ref class Patcher{
List<double> ^getAllPoints(List<long long>^ paths,STEPNCLib::Finder ^find);
void patchRapid(List<long long>^ pathList,STEPNCLib::AptStepMaker ^ apt, STEPNCLib::Finder ^find,double max_feed);
void appendPatchWorkPlan(String^partFile,String^coorFile,String^outName,String^ path,bool toInches );
void createPatchedFile(String^ partFile,String^ WPpath,String^newFileName,String^newWorkPlan,String^ coor,bool toInches);
void createPatchedFile(String^ partFile,String^ WPpath,String^newFileName,String^newWorkPlan,String^ coor);
//ToolPath^ firstPath(__int64 root);
void DeleteBefore(__int64 wpid, STEPNCLib::Finder ^find, STEPNCLib::AptStepMaker^apt);

};
#endif
82 changes: 78 additions & 4 deletions ToolPath.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,88 @@
#include "ToolPath.h";
#include "ToolPath.h"
#include"stdafx.h"

/*
ToolPath^ ToolPath::nextPath(){
if(parent!=nullptr){
return dynamic_cast<ToolPath^>(dynamic_cast<WS^>(parent)->getPath(getIndex()+1));
return (parent)->getPath(getIndex()+1);

}else{

Console::WriteLine("Error path is not nested in a WS");
return nullptr;}
return nullptr;
}
*/


ToolPath::ToolPath(WS^ p, bool rapid, double f, double s, __int64 in, __int64 ID) {
parent = p;
isRapid = rapid;
feedrate = f;
spindleSpeed = s;
index = in;
id = ID;

}
WS^ ToolPath::getWS() { return parent; }
__int64 ToolPath::getId(){ return id; }
__int64 ToolPath::getIndex() { return index; }

ToolPath^ ToolPath::nextPath(bool % newWP, bool% newWS) {
ToolPath^temp =nextPath();
Exec^ tempExec;
if (temp != nullptr) {
newWP = false;
newWS = false;
return temp;
}
else {
WS^ tempWS = getWS();
ToolPath^ nextToolPath = nullptr;
List<WP^>^path = getWS()->pathtoRoot();
for (int i = 0; i<path->Count; i++) {
nextToolPath = recurseToNextToolPath(path[i], tempWS->getIndex());


}
}
}

ToolPath^ ToolPath::recurseToNextToolPath(WP^ current, __int64 startIndexAfter) {
ToolPath^ result = nullptr;
for (int i = startIndexAfter + 1; i<current->getExecutableCount(); i++) {
result = recurseToolPath(current->getExecutable(i));
if (result != nullptr) {
return result;
}
}


}
ToolPath^ ToolPath::recurseToolPath(Exec^ current) {
WS^ tempWS = nullptr;
WP^ tempWP = nullptr;
WP^ tempWP2;
if (current->isWP()) {
tempWP = dynamic_cast<WP^>(current);
}
else {
tempWS = dynamic_cast<WS^>(current);
}
if (tempWS != nullptr) {
if (tempWS->getPathCount()>0) {
return tempWS->getPath(0);

}
}
if (tempWP != nullptr) {
for (int i = 0; i<tempWP->getExecutableCount(); i++) {

return recurseToolPath(tempWP->getExecutable(i));


}


}
return nullptr;
}

28 changes: 13 additions & 15 deletions ToolPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ using namespace System::Net;
using namespace System::Collections::Generic;
using namespace System::IO;
using namespace System::Text;
#pragma once

#ifndef __TOOLPATH__
#define __TOOLPATH__
#include "Exec.h"

#include "WS.h"

ref class ToolPath
{
Expand All @@ -17,25 +18,22 @@ ref class ToolPath
double feedrate;
__int64 index;
__int64 id;
Exec^ parent;
WS^ parent;




public:
ToolPath(Exec^ p,bool rapid,double f,double s,__int64 in, __int64 ID){
parent=p;
isRapid=rapid;
feedrate=f;
spindleSpeed=s;
index=in;
id=ID;
ToolPath(WS^ p, bool rapid, double f, double s, __int64 in, __int64 ID);
WS^ getWS();

}
Exec^ getWS(){return parent;};
Exec^getWP(){return parent->getParent();}
__int64 getId(){return id;}
__int64 getIndex(){return index;}
__int64 getId();
__int64 getIndex();

ToolPath^ nextPath();
ToolPath^ nextPath(bool % newWP, bool% newWS);
ToolPath^ recurseToNextToolPath(WP^ current, __int64 startIndexAfter);
ToolPath^ recurseToolPath(Exec^ current);
//get pointer to next path regardless if it is a new WS or WP
//null if non exist
/*
Expand Down
37 changes: 37 additions & 0 deletions WP.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include"WP.h"
#include"stdafx.h"

Exec^ WP::getExecutable(__int64 i){ if (i<getExecutableCount()) { return execList[i]; } };
void WP::addExecutable(Exec^ e) { execList->Add(e); };

__int64 WP::getExecutableCount() { return execList->Count; };

WP::WP(String^ n, __int64 ID, __int64 in, WP^p) :Exec(n, ID, in, p, true) {
execList = gcnew List<Exec^>();
};


ToolPath ^ WP::firstPath(WP^ root) {
if (root == nullptr) {
root = this;
}
Exec^tempExec;
WP^ tempWP;
WS^ tempWS;
for (int i = 0; i<root->getExecutableCount(); i++) {
tempExec = root->getExecutable(i);
if (tempExec->isWP()) {
tempWP = dynamic_cast<WP^>(tempExec);
return firstPath(tempWP);
}
else {
tempWS = dynamic_cast<WS^>(tempWS);
return tempWS->getPath(0);

}


}
return nullptr;

};
Loading

0 comments on commit ec6b784

Please sign in to comment.