Skip to content

Commit

Permalink
Merge pull request #10 from HAW-MT-Jg2013/development
Browse files Browse the repository at this point in the history
all tested with machine
  • Loading branch information
Jannik Beyerstedt authored and Jannik Beyerstedt committed Dec 16, 2014
2 parents 157831a + 50c6e0c commit 4670664
Show file tree
Hide file tree
Showing 36 changed files with 4,349 additions and 60 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
*.vpp~*

*.pages

Programm/build
Programm/dist
128 changes: 128 additions & 0 deletions Programm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#
# There exist several targets which are by default empty and which can be
# used for execution of your targets. These targets are usually executed
# before and after some main targets. They are:
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
#
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
#
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_PLATFORM_${CONF} platform name (current configuration)
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL


# Environment
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin


# build
build: .build-post

.build-pre:
# Add your pre 'build' code here...

.build-post: .build-impl
# Add your post 'build' code here...


# clean
clean: .clean-post

.clean-pre:
# Add your pre 'clean' code here...

.clean-post: .clean-impl
# Add your post 'clean' code here...


# clobber
clobber: .clobber-post

.clobber-pre:
# Add your pre 'clobber' code here...

.clobber-post: .clobber-impl
# Add your post 'clobber' code here...


# all
all: .all-post

.all-pre:
# Add your pre 'all' code here...

.all-post: .all-impl
# Add your post 'all' code here...


# build tests
build-tests: .build-tests-post

.build-tests-pre:
# Add your pre 'build-tests' code here...

.build-tests-post: .build-tests-impl
# Add your post 'build-tests' code here...


# run tests
test: .test-post

.test-pre: build-tests
# Add your pre 'test' code here...

.test-post: .test-impl
# Add your post 'test' code here...


# help
help: .help-post

.help-pre:
# Add your pre 'help' code here...

.help-post: .help-impl
# Add your post 'help' code here...



# include project implementation makefile
include nbproject/Makefile-impl.mk

# include project make variables
include nbproject/Makefile-variables.mk
13 changes: 13 additions & 0 deletions Programm/Sources/FestoProcessAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
FestoProcessAccess::FestoProcessAccess(FestoProcessImage* processImage) {
timeCounter = 0;
process = processImage;
plugin = NULL;

#ifdef LOG_PROCESS
logFile = fopen("c:\\tmp\\processlog.txt","w");
Expand All @@ -32,6 +33,10 @@ FestoProcessAccess::~FestoProcessAccess() {
}
}

void FestoProcessAccess::addPlugin(Plugin *heightPlugin) {
plugin = heightPlugin;
}

void FestoProcessAccess::updateInputs(void) {
timeCounter = time(NULL);
process->updateProcessImage();
Expand All @@ -50,21 +55,25 @@ void FestoProcessAccess::applyOutput(void) {

void FestoProcessAccess::driveRight(void) {
process->setBitInOutput(DRIVE_DIRECTION_RIGHT);
process->clearBitInOutput(DRIVE_DIRECTION_LEFT);
process->clearBitInOutput(DRIVE_STOP);
}

void FestoProcessAccess::driveLeft(void) {
process-> setBitInOutput(DRIVE_DIRECTION_LEFT);
process-> clearBitInOutput(DRIVE_DIRECTION_RIGHT);
process-> clearBitInOutput(DRIVE_STOP);
}

void FestoProcessAccess::driveSlowRight(void) {
process->setBitInOutput(DRIVE_DIRECTION_RIGHT | DRIVE_SLOW);
process->clearBitInOutput(DRIVE_DIRECTION_LEFT);
process->clearBitInOutput(DRIVE_STOP);
}

void FestoProcessAccess::driveSlowLeft(void) {
process->setBitInOutput(DRIVE_DIRECTION_LEFT | DRIVE_SLOW);
process->clearBitInOutput(DRIVE_DIRECTION_RIGHT);
process->clearBitInOutput(DRIVE_STOP);
}

Expand Down Expand Up @@ -149,6 +158,10 @@ bool FestoProcessAccess::isItemAtHightSensor(void) {
return !(process->isBitSet(ITEM_AT_HIGHT_SENSOR)); // active low
};

bool FestoProcessAccess::hasItemCorrectHight(void) {
return !(plugin->result()); // true is item with defect
}

bool FestoProcessAccess::isItemAtMetalDetector(void) {
return !(process->isBitSet(ITEM_AT_JUNCTION)); // active low
}
Expand Down
4 changes: 4 additions & 0 deletions Programm/Sources/FestoProcessAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@

#include "FestoProcessSensors.h"
#include "processimage.h"
#include "plugin.h"

#define LOG_PROCESS

class FestoProcessAccess : public FestoProcessSensors {
private:
time_t timeCounter;
FestoProcessImage* process;
Plugin* plugin;
FILE* logFile;

public:
FestoProcessAccess(FestoProcessImage* processImage);
virtual ~FestoProcessAccess();
void addPlugin(Plugin* heightPlugin);
public:
void updateInputs(void);
void applyOutput(void);
Expand Down Expand Up @@ -57,6 +60,7 @@ class FestoProcessAccess : public FestoProcessSensors {

virtual bool isItemAtBeginning(void);
virtual bool isItemAtHightSensor(void);
virtual bool hasItemCorrectHight(void);
virtual bool isItemAtMetalDetector(void);
virtual bool isMetalDetected(void);
virtual bool isJunctionOpen(void);
Expand Down
2 changes: 1 addition & 1 deletion Programm/Sources/FestoProcessSensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FestoProcessSensors {
public:
virtual bool isItemAtBeginning(void) = 0;
virtual bool isItemAtHightSensor(void) = 0;
//virtual bool hasItemCorrectHight(void)= 0;
virtual bool hasItemCorrectHight(void)= 0;
virtual bool isItemAtMetalDetector(void) = 0;
virtual bool isMetalDetected(void) = 0;
virtual bool isJunctionOpen(void) = 0;
Expand Down
104 changes: 101 additions & 3 deletions Programm/Sources/HeightProfileCheck.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,107 @@
*
* class for checking the height profile of the items
*
* \author Jannik Beyerstedt
* \version 0.1
* \date 2014-11-25
* \author Jannik Beyerstedt, Daniel Friedrich
* \version 0.2
* \date 2014-12-08
*/

#include "HeightProfileCheck.h"


HeightProfileCheck::HeightProfileCheck(FestoProcessSensors *process) {
this->process = process;
currentState = H_Standby;

logFile.open("hightCheckLog.txt");
}

HeightProfileCheck::~HeightProfileCheck() {
this->process = NULL;

logFile.close();
}

void HeightProfileCheck::evalCycle() {
evalEvents();
evalState();
}

void HeightProfileCheck::evalEvents() {
unsigned short height = process->getHight();
heights heightLevel = Incorrect;

if ( (lowVal-tolSmall) <= height && height <= (lowVal+tolSmall) ) {
heightLevel = Low;
}else if ( (midVal-tolWide) <= height && height <= (midVal+tolWide) ) {
heightLevel = Middle;
}else if ( (highVal-tolWide) <= height && height <= (highVal+tolWide) ) {
heightLevel = High;
}else {
heightLevel = Incorrect;
}


switch (currentState) {
case H_Standby:
if (heightLevel == High) {
currentState = ItemDetected;
}
break;
case ItemDetected:
if (heightLevel == Low) {
currentState = H_Standby;
}else if (heightLevel == Middle) {
currentState = ItemWrong;
}
break;
case ItemWrong:
if (heightLevel == High) {
currentState = WrongType2;
}else if (heightLevel == Low) {
currentState = WrongType1;
}
break;
case WrongType1:
currentState = H_Standby;
break;
case WrongType2:
currentState = H_Standby;
break;
default:
break;
}
}

void HeightProfileCheck::evalState() {
switch (currentState) {
case H_Standby:
itemDiagnosis = 0;
break;
case WrongType1:
itemDiagnosis = 1;
logDefectType("defect type 1");
break;
case WrongType2:
itemDiagnosis = 1;
logDefectType("defect type 2");
break;

default:
break;
}

}

bool HeightProfileCheck::result() {
return itemDiagnosis;
}

void HeightProfileCheck::logDefectType(std::string defectDescription) {
if (logFile.is_open()) {
logFile << time(NULL) << " wrong item: " << defectDescription << std::endl;
std::cout << time(NULL) << " wrong item: " << defectDescription << std::endl;
}else {
std::cout << "logfile can´t be accessed" << std::endl;
}
}
Loading

0 comments on commit 4670664

Please sign in to comment.