Click here to Skip to main content
15,901,373 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CWinthread Pin
Mark Salsbery5-Mar-08 13:40
Mark Salsbery5-Mar-08 13:40 
GeneralRe: CWinthread Pin
LCI6-Mar-08 1:20
LCI6-Mar-08 1:20 
GeneralRe: CWinthread Pin
LCI6-Mar-08 1:33
LCI6-Mar-08 1:33 
GeneralRe: CWinthread Pin
Mark Salsbery6-Mar-08 5:10
Mark Salsbery6-Mar-08 5:10 
GeneralRe: CWinthread Pin
Mark Salsbery6-Mar-08 5:14
Mark Salsbery6-Mar-08 5:14 
GeneralService or Singleton COM exe or DLL Pin
act_x5-Mar-08 11:13
act_x5-Mar-08 11:13 
GeneralRe: Service or Singleton COM exe or DLL Pin
Matthew Faithfull5-Mar-08 12:23
Matthew Faithfull5-Mar-08 12:23 
Generalusing New Opperator for object pointers ( Polymorphism ) Pin
ScotDolan5-Mar-08 10:07
ScotDolan5-Mar-08 10:07 
I have two different object CLX_MITSUBISHI_POLLING and CLX_LENZE_POLLING. These two classes both inherit four other classes that are similar but not identical. The functions names and parameter of the different inherited classes are identical but the code is not.

I am have difficultly finding a way to create a generic class object pointer and then useing the new operator. I am finding it difficult because, i don't have a way to create a generic base class because of the four other objects inherited(CLX_LENZE_LIFT_INVERTOR,etc.) I was thinking may i could do something with templates or null pointer( void *inverter; inverter = new CLX_MITSUBISHI_POLLING();) Unfortunately, the null pointer did not work. Any recommendations would be greatly a appreciated.

Cheers Scott

<br />
CLX_POLLING *Invertors;<br />
<br />
if( inverter_type == MITSUBISHI  )<br />
   Invertors = new CLX_MITSUBISHI_POLLING;<br />
else <br />
   Invertors = new CLX_LENZE_POLLING;<br />




My CLX_MITSUBISHI_POLLING clases
<br />
#pragma once<br />
#include "windows.h"<br />
#include "ClxThread.h"<br />
#include "ClxSafeQue.h"<br />
#include "ClxMitsubishiParameters.h"<br />
#include "ClxMitsubishiLiftInvertor.h"<br />
#include "ClxMitsubishiPitchInvertor.h"<br />
#include "ClxMitsubishiRollInvertor.h"<br />
#include "ClxMitsubishiCounterWeightInvertor.h"<br />
<br />
class CLX_MITSUBISHI_POLLING : <br />
	public  ClxThread,<br />
		public CLX_MITSUBISHI_PITCH_INVERTOR,<br />
			public CLX_MITSUBISHI_ROLL_INVERTOR,<br />
				public	CLX_MITSUBISHI_LIFT_INVERTOR,<br />
					public	CLX_MITSUBISHI_COUNTERWEIGHT_INVERTOR<br />
{<br />
	public:<br />
		CLX_MITSUBISHI_POLLING(void);<br />
		~CLX_MITSUBISHI_POLLING(void);<br />
		bool					mStartPolling(void){ return CreateNewThread(); }	<br />
<br />
<br />
	private:		// Serial Port Specific Commands and Data<br />
		unsigned short			m_BaudRate;<br />
		int						m_CommPort;<br />
		int						m_SerialPortHandlePolling;	<br />
	public:	<br />
		bool					mvInitComm( int comm_port, int baud_rate );<br />
		bool					mvCloseComm( void );<br />
		bool					mvRestartComm( void );	<br />
		void					mvSetBaudRate(int value);<br />
		unsigned short			mvGetBaudRate(void);<br />
		void					mvSetCommPort(int value);<br />
		unsigned short			mvGetCommPort(void);<br />
		int						mvGetSerialPortHandle( void );<br />
		void					mvSetSerialPortHandle( int );<br />
	private:<br />
		int						mvPutByte( char txdata );<br />
		int						mvPutPacket( int lenght, char txdata[] );	<br />
		int						mvGetBytes( void );<br />
		int						mvFlushRxBuf( void );<br />
		int						mvFlushTxBuf( void );<br />
		int						mvGetRxBuf(void);<br />
		int						mvGetTxBuf(void);	<br />
		bool					mvIsOverrunErrors(void);<br />
		bool					mvIsParityErrors(void);<br />
		bool					mvIsRxBufferEmpty(void);<br />
		bool					mvIsTxBufferEmpty(void);<br />
		int						mvGetRxBufferSize(void);<br />
		int						mvGetTxBufferSize(void);<br />
	private:   <br />
		void					ThreadRun(void);<br />
		CRITICAL_SECTION		m_csMitsubishiPolling;<br />
};



My CLX_LENZE_POLLING clases
#pragma once<br />
#include "windows.h"<br />
#include "ClxThread.h"<br />
#include "ClxSafeQue.h"<br />
#include "ClxLenzeRollInvertor.h"<br />
#include "ClxLenzeLiftInvertor.h"<br />
#include "ClxLenzePitchInvertor.h"<br />
#include "ClxLenzeCounterWeightInvertor.h"<br />
<br />
<br />
<br />
class CLX_LENZE_POLLING : <br />
	public  ClxThread,<br />
		public CLX_LENZE_PITCH_INVERTOR,<br />
			public CLX_LENZE_ROLL_INVERTOR,<br />
				public CLX_LENZE_LIFT_INVERTOR,<br />
					public CLX_LENZE_COUNTERWEIGHT_INVERTOR<br />
{<br />
	public:<br />
		CLX_LENZE_POLLING(void);<br />
		~CLX_LENZE_POLLING(void);<br />
			bool				mStartPolling(void){ return CreateNewThread(); }	<br />
<br />
	private:   <br />
		void					ThreadRun(void);<br />
		CRITICAL_SECTION		m_csLenzePolling;<br />
<br />
	private:		// Serial Port Specific Commands and Data<br />
		unsigned short			m_BaudRate;<br />
		int						m_CommPort;<br />
		int						m_AllSerialPortHandle;	<br />
	public:	<br />
		bool					mvInitComm( int comm_port, int baud_rate );<br />
		bool					mvCloseComm( void );<br />
		bool					mvRestartComm( void );	<br />
		void					mvSetBaudRate(int value);<br />
		unsigned short			mvGetBaudRate(void);<br />
		void					mvSetCommPort(int value);<br />
		unsigned short			mvGetCommPort(void);<br />
		int						mvGetSerialPortHandle( void );<br />
		void					mvSetSerialPortHandle( int );<br />
	private:<br />
		int						mvPutByte( char txdata );<br />
		int						mvPutPacket( int lenght, char txdata[] );	<br />
		int						mvGetBytes( void );<br />
		int						mvFlushRxBuf( void );<br />
		int						mvFlushTxBuf( void );<br />
		int						mvGetRxBuf(void);<br />
		int						mvGetTxBuf(void);	<br />
		bool					mvIsOverrunErrors(void);<br />
		bool					mvIsParityErrors(void);<br />
		bool					mvIsRxBufferEmpty(void);<br />
		bool					mvIsTxBufferEmpty(void);<br />
		int						mvGetRxBufferSize(void);<br />
		int						mvGetTxBufferSize(void);<br />
	<br />
<br />
<br />
<br />
	<br />
<br />
		<br />
};




All the below classes are identical except for function name which will be Lift, Roll, Pitch, or CounterWeight accordingly. The inherited PARAMETERS contains function to send and recieve packets. It also has a some virtual function such as mvGetByte, mvPutByte. mvSetCommPort. This virtual function are overrided in CLX_MITSUBISHI_POLLING and CLX_LENZE_POLLING so the all the inherited classes use the same serial port. The only differents in LENZE or MITSUBISHI is in the individual functions.
CLX_LENZE_PITCH_INVERTOR
CLX_LENZE_ROLL_INVERTOR
CLX_LENZE_LIFT_INVERTOR
CLX_LENZE_COUNTERWEIGHT_INVERTOR
CLX_MITSUBISHI_PITCH_INVERTOR
CLX_MITSUBISHI_ROLL_INVERTOR
CLX_MITSUBISHI_LIFT_INVERTOR
CLX_MITSUBISHI_COUNTERWEIGHT_INVERTOR

<br />
#pragma once<br />
#include "Windows.h"<br />
#include "ClxSafeQue.h"<br />
#include "ClxMitsubishiParameters.h"<br />
<br />
<br />
class CLX_MITSUBISHI_LIFT_INVERTOR : <br />
	public CLX_MITSUBISHI_PARAMETERS<br />
{<br />
public:<br />
	CLX_MITSUBISHI_LIFT_INVERTOR(void);<br />
	~CLX_MITSUBISHI_LIFT_INVERTOR(void);<br />
<br />
	void   LiftSetAddress( char address );		<br />
	char   LiftGetAddress( void );	<br />
<br />
	void   LiftSetJogFrequency( double value );<br />
	double LiftGetJogFrequency( void );<br />
<br />
	void   LiftSetConfigurationVoltage( int volts );	<br />
	int    LiftGetConfigurationVoltage( void );	<br />
	<br />
	bool   LiftisConnected( void );<br />
	bool   LiftisInhibited( void );<br />
	bool   LiftisActiveFault( void );<br />
	bool   LiftisBootMode( void );<br />
	bool   LiftisSerialMode( void );<br />
	bool   LiftisAnalogMode( void );<br />
	bool   LiftisUnknownMode( void ); <br />
		<br />
	bool   LiftGetBusVoltage( double *dTemp);<br />
	bool   LiftGetOutputVoltage( double *dTemp);			<br />
	bool   LiftGetOutputCurrent( double *dTemp);			<br />
	bool   LiftGetOutputFrequencey( double *dTemp);	<br />
	bool   LiftGetOutputTemperature( double *dTemp );<br />
	bool   LiftGetPoweronTime( double *dTemp);				<br />
	bool   LiftGetOperatingTime( double *dTemp);	<br />
		<br />
	bool   LiftGetActiveFault( int *iTemp );			<br />
	bool   LiftGetLastFault( int *iTemp);			<br />
	bool   LiftGetLastFault2( int *iTemp);				<br />
	bool   LiftGetLastFault3( int *iTemp);				<br />
<br />
	bool   LiftInitDefaultsCmd(void);				<br />
	bool   LiftDriveStateCmd(void);				<br />
	bool   LiftAutotuneCmd(void);		<br />
	bool   LiftEnableCmd( void );				<br />
 	bool   LiftDisableCmd( void );					<br />
 	bool   LiftAnalogModeCmd( void );				<br />
	bool   LiftAnalogBrakeNormalCmd( void );	<br />
	bool   LiftAnalogBrakeInvertedCmd( void );<br />
	bool   LiftSerialModeCmd( void );		  <br />
	bool   LiftSerialBrakeNormalCmd( void );		<br />
	bool   LiftSerialBrakeInvertedCmd( void );		<br />
	bool   LiftResetFaultsCmd( void );					<br />
	bool   LiftJogCwCmd( void );			 	<br />
	bool   LiftJogCcwCmd( void );				<br />
	bool   LiftJogStopCmd( void );					<br />
<br />
	void   LiftDisableParity( void )			{	DisableParity();	}<br />
	void   LiftEnableParity( void )				{	EnableParity();		}<br />
	bool   LiftGetParity( void )				{   GetParity();		}<br />
	void   LiftSetRxTimeout( unsigned long value )		{	SetReceiveTimeout(value); }<br />
	int    LiftGetRxTimeout( void )				{   return GetReceiveTimeout(); }<br />
	void   LiftSetRxRetryNum( int value );			<br />
	int    LiftGetRxRetryNum( void );<br />
<br />
	void   LiftRun( void );<br />
<br />
private:<br />
	bool   LiftActivateCmd( char incmd );<br />
	<br />
	ClxSafeQue<char>	m_sqCmdQue;<br />
	CRITICAL_SECTION	m_csLock;	<br />
<br />
	char	m_cAddress;// This is the address of the lift inverter. This value should never change<br />
	double	m_dJogFrequency;	// Jog 		<br />
	int	m_cConfigurationVoltage;	<br />
	bool	m_bActiveFault;	// Indicates if there is a active fault<br />
	bool	m_bConnected;	// Indicates if there drive or software is problems<br />
	bool	m_bInhibited;				// Indicates if the drive is inhibited<br />
	bool	m_bIsBootMode;				// Boot<br />
	bool	m_bIsSerialMode;			// Serial<br />
	bool	m_bIsAnalogMode;			// Analog<br />
	bool	m_bIsUnknownMode;			// Unknown<br />
	bool	m_bValidDriveState;	<br />
	double	m_dBusVoltage;				// Holds the current drive bus voltage<br />
	bool	m_bValidBusVoltage;		<br />
	double	m_dOutputVoltage;	// Holds the current drive output voltage<br />
	bool	m_bValidOutputVoltage;		<br />
	double	m_dOutputCurrent;			<br />
	bool	m_bValidOutputCurrent;			<br />
	double	m_dOutputFrequencey;	<br />
	bool	m_bValidOutputFrequencey;	<br />
	double	m_dOutputTemperature;	<br />
	bool	m_bValidOutputTemperature;	<br />
	double	m_dOperatingTime;			<br />
	bool	m_bValidOperatingTime;		<br />
	double	m_dPowerOnTime;				// Holds the drives Power On Time <br />
	bool	m_bValidPowerOnTime;		<br />
	int	m_iActiveFault;				// Holds the most recent fault<br />
	bool	m_bValidActiveFault;			<br />
	int	m_iLastFault;				<br />
	bool	m_bValidLastFault;		<br />
<br />
	int	m_iLastFault2;				// Holds the thrid most recent fault<br />
	bool	m_bValidLastFault2;			<br />
<br />
	int	m_iLastFault3;				// Holds the Fourth most recent fault<br />
	bool	m_bValidLastFault3;				<br />
<br />
	<br />
	unsigned long		m_lCurrentNumTxPktFailed;	<br />
	unsigned long		m_iMaxinumNumTxPktFailures;	<br />
	unsigned long		m_lTotalNumTxPktFailed;	<br />
	unsigned long		m_lTotalNumTxPktCount;	<br />
	char			m_cPollingCommandIndex;<br />
<br />
<br />
};<br />
<br />


Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures

GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
led mike5-Mar-08 11:34
led mike5-Mar-08 11:34 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
ScotDolan5-Mar-08 12:18
ScotDolan5-Mar-08 12:18 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Randor 5-Mar-08 13:06
professional Randor 5-Mar-08 13:06 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Mark Salsbery5-Mar-08 14:16
Mark Salsbery5-Mar-08 14:16 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
led mike6-Mar-08 6:09
led mike6-Mar-08 6:09 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Mark Salsbery6-Mar-08 6:12
Mark Salsbery6-Mar-08 6:12 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
led mike6-Mar-08 6:31
led mike6-Mar-08 6:31 
GeneralKnowing if the Application is already beeing executed (Previnstance) Pin
marcio kovags5-Mar-08 7:44
marcio kovags5-Mar-08 7:44 
GeneralRe: Knowing if the Application is already beeing executed (Previnstance) Pin
Randor 5-Mar-08 7:57
professional Randor 5-Mar-08 7:57 
GeneralRe: Knowing if the Application is already beeing executed (Previnstance) Pin
Joan M5-Mar-08 7:59
professionalJoan M5-Mar-08 7:59 
GeneralRe: Knowing if the Application is already beeing executed (Previnstance) Pin
CPallini5-Mar-08 8:04
mveCPallini5-Mar-08 8:04 
AnswerRe: Knowing if the Application is already beeing executed (Previnstance) Pin
Roger Stoltz5-Mar-08 21:12
Roger Stoltz5-Mar-08 21:12 
GeneralWindows Service Pin
act_x5-Mar-08 6:59
act_x5-Mar-08 6:59 
GeneralRe: Windows Service Pin
Joan M5-Mar-08 7:19
professionalJoan M5-Mar-08 7:19 
GeneralRe: Windows Service Pin
Mark Salsbery5-Mar-08 11:53
Mark Salsbery5-Mar-08 11:53 
GeneralRe: Windows Service Pin
Randor 5-Mar-08 8:13
professional Randor 5-Mar-08 8:13 
QuestionSelf-registered edit control class crashes because of wrong GetWindowTextLength return value Pin
Skarrin5-Mar-08 6:50
Skarrin5-Mar-08 6:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.