Click here to Skip to main content
15,886,724 members
Articles / Programming Languages / C++

An Automated System with Pipeline Concurrent Kernel

Rate me:
Please Sign up or sign in to vote.
3.46/5 (4 votes)
26 Jan 2007CPOL17 min read 25.6K   247   15  
A multithreaded solution is provided as a concurrent pipeline kernel for an automated bartender machine. The application engine can pipeline three of four different kinds of cocktail recipes for the system.
#ifndef RESOURCE4_H
#define RESOURCE4_H

//
// Note: 
// 
// In this sample, synchronization resource and custom activity resource are the same. The reason to
// implement custom activity resource is to illustrate resource action.
//
// A task can occupy more than one custom activity resource.
//

// Define synchronization resource
#define SR_R								"Robot with arm"
#define SR_P2								"P2"
#define SR_P3								"P3"
#define SR_P4								"P4"

// Define custom activity resource
#define AR_R								"Robot with arm"
#define AR_P1								"P1"
#define AR_P2								"P2"
#define AR_P3								"P3"
#define AR_P4								"P4"

class CAutoBartender1Dlg;

//-- CActivityResourceBase
class CActivityResourceBase: public knActivityResource
{
protected:
	CAutoBartender1Dlg		*m_pDlg;

public:
	CActivityResourceBase(LPCSTR psName, CAutoBartender1Dlg *pDlg);
	virtual ~CActivityResourceBase();

	void							OutputActivityText(long lControlIndex, knTask *pTask);

	// This function is only called by ResourceNotify__End_Occupy().
//	void							OutputPlatformRobotResult(long lControlIndex, knTask *pTask);
};

//-- CActivityResource_R 
class CActivityResource_R: public CActivityResourceBase
{
public:
	CActivityResource_R(CAutoBartender1Dlg *pDlg);

	virtual void					ResourceNotify__Begin_Occupy(knTask *pTask);
	virtual void					ResourceNotify__End_Occupy(knTask *pTask);
};

//-- CActivityResource_P1
class CActivityResource_P1: public CActivityResourceBase
{
public:
	CActivityResource_P1(CAutoBartender1Dlg *pDlg);

	virtual void					ResourceNotify__Begin_Occupy(knTask *pTask);
	virtual void					ResourceNotify__End_Occupy(knTask *pTask);
};

//-- CActivityResource_P2
class CActivityResource_P2: public CActivityResourceBase
{
public:
	CActivityResource_P2(CAutoBartender1Dlg *pDlg);

	virtual void					ResourceNotify__Begin_Occupy(knTask *pTask);
	virtual void					ResourceNotify__End_Occupy(knTask *pTask);
};

//-- CActivityResource_P3
class CActivityResource_P3: public CActivityResourceBase
{
public:
	CActivityResource_P3(CAutoBartender1Dlg *pDlg);

	virtual void					ResourceNotify__Begin_Occupy(knTask *pTask);
	virtual void					ResourceNotify__End_Occupy(knTask *pTask);
};

//-- CActivityResource_P4
class CActivityResource_P4: public CActivityResourceBase
{
public:
	CActivityResource_P4(CAutoBartender1Dlg *pDlg);

	virtual void					ResourceNotify__Begin_Occupy(knTask *pTask);
	virtual void					ResourceNotify__End_Occupy(knTask *pTask);
};


#endif // RESOURCE4_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions