Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Hello all Can anyone has a program on waching machine with C++. I want to learn ho

Status
Not open for further replies.

basilebeauclair

Newbie level 1
Joined
Feb 14, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
London
Activity points
1,287
Hello all Can anyone has a program on waching machine with C++. I want to learn how to program it
 

Hello all Can anyone has a program on waching machine with C++. I want to learn how to program it

Yes, we would love to help you but first of all explain what is this "waching machine" suppose to do.
 
Last edited:

Hello all Can anyone has a program on waching machine with C++. I want to learn how to program it
yes but no
i cant help you with firmware you can always see whats going on using a logic analyzer and the real machine
most of it is written in c
c++ is not !! used mostly for crytical stuff like life keeping
washing machines are also written in c but too a company's own development stuff
other than to look to a washing machine you like
and works
and copy/clone its routines so you need a timer and a delay routine's and interrupts
then you'll gauge far more info than looking for others code!!
for instance
first you write a flow chart
in a washing machine you have water in water out level sensor{vacuum switch on the pump}
and the pump cycle/ heating .. mix of routines.. is needed

so there is a basic flow chart

so do this for c++ the hierarchies of c c++ are triangles
c++is triangle with brackets with other parts of the same triangles or more

like

.
..
...
....
.....
etc

code is execed like down always by the clock of the chip rom ram etc
the clock of a code is its thread!!! always down {but can reuse functions above!! easy}
with respect to timers int's and clocks port schedules etc

down

|
|
|>
|>
// the stubs!!!
//your header is even in main c++class
// bindings to pins are here as #defines
VOID MAIN(void)
VOID callback()
VOID door_closed(void)
VOID door open(void)
VOID heat_level_onoff(void)
VOID water_intake(void)
VOID pump _cycle(void)
VOID motor_cycle_spinup(void)|>

so you need to include stuff with stubs
as above routines that use the function
in terms of hierarchies so its there!! to use
you class is
class actions are inside the {}

{routines group struct}

VOID motor_cycle_spinup(void){}
VOID pump _cycle(void){}
VOID water_intake(void){}
VOID heat_level_onoff(void){}
VOID door open(void){}
VOID door_closed(void){}
VOID MAIN(void){}
VOID callback(){}


header or class based
code always... exe's top down but can inc previous and sub rotuines
you'll notice i placed motor_cycle() first
so its included in all further routines within the class

always add a header or a 'routine's structure'
it helps you control the routine's structure in terms of the hierarchies you want or need
to evaluate the main schedule

you can add to the voids{not VOIDS} indirect
so.. this is c++
you need to do a header .h and add then in the header..
or add the routines in class as stubs {exactly as above c++ adds virtual class structures}
you can pass variables in a c++ class by #define a global var
or a ordinal of vars
like
#spin 1
#nospin 2
#pump 4
#door 8
etc
this is a word base ordinal
anyway i hope you get a few books
but some reading on line is good

go to planet source and im sure you can ' find ' there iso''s of premade code to explore

ignore the other two guys they know nothing really
 
Last edited:

So, your "waching machine" is actually a washing machine!!!!!!!!
I think you want the code for your school project and not for microprocessor based application.
If this is the case, the following may help you:-
////////////////////////////////////////////////////
///////////////////WashingMachine.h///////////////////////////////////

#ifndef __WASHING_MACHINE__
#define __WASHING_MACHINE__

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

class WashingMachineContext;


class WashingMachine
{

public:
WashingMachine();

~WashingMachine();

void Process();

int GetRtxCounter() const {return iRtxCount;}

// Events
void Start();
void WashingDone();
void RinsingDone();
void SpinningDone();
void Fault();
void DiagnoseSuccess();

// Actions
void Print(const string& message);

private:

WashingMachineContext& GetContext();
WashingMachineContext *m_pContext;
int iRtxCount;
int iCounter;
};

#endif

/////////////////////////////////////////////////////

//////////////////////WashingMachine.cpp///////////////////////////////
#include <stdexcept>
#include <ObserverStd.h>
#include "WashingMachine.h"
#include "WashingMachineFsm.h"
#include <iostream>

using namespace std;

WashingMachine::WashingMachine()
{
m_pContext = new WashingMachineContext(*this);
m_pContext->SetObserver(fsm::ObserverStd::GetInstance());
m_pContext->EnterInitialState();
}

WashingMachine::~WashingMachine()
{
delete m_pContext;
}

WashingMachineContext& WashingMachine::GetContext()
{
if(m_pContext != NULL){
return *m_pContext;
} else {
throw std::runtime_error("context is not set");
}
}

void WashingMachine::Start()
{
GetContext().Start();
}

void WashingMachine::WashingDone()
{
GetContext().WashingDone();
}

void WashingMachine::RinsingDone()
{
GetContext().RinsingDone();
}

void WashingMachine::SpinningDone()
{
GetContext().SpinningDone();
}

void WashingMachine::Fault()
{
GetContext().Fault();
}

void WashingMachine::DiagnoseSuccess()
{
GetContext().DiagnoseSuccess();
}

void WashingMachine::print(const string& message)
{
cout << message << endl;
}
///////////////////////////////////////////////////////////
/////////////////////main.cpp//////////////////////////////////
#include <iostream>
#include <cstdlib>
#include <iostream>


#include "main.h"
#include "WashingMachine.h"

using namespace std;


int main(int, char **)
{
App app;
return app.Main();
}


App::App()
{
}

int App::Main()
{
cout << "WashingMachine" << endl;
try {

WashingMachine washingMachine;
cout << "WashingMachine has been created" << endl;
cout << "Send Start" << endl;
washingMachine.Start();
cout << "Send WashingDone" << endl;
washingMachine.WashingDone();
cout << "Send Fault" << endl;
washingMachine.Fault();
cout << "Send DiagnoseSuccess" << endl;
washingMachine.DiagnoseSuccess();
cout << "Send RinsingDone" << endl;
washingMachine.RinsingDone();
cout << "Send Fault" << endl;
washingMachine.Fault();
cout << "Send DiagnoseSuccess" << endl;
washingMachine.DiagnoseSuccess();
cout << "Send SpinningDone" << endl;
washingMachine.SpinningDone();
cout << "Done with events" << endl;
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << "\n";
return -1;
}
cout << "WashingMachine should have been destroyed by this time" << endl;
return 0;
}

///////////////////////////////

This is for idea only.
you can see this site for more (xml files etc) WashingMachine

If want a console based program, the class structure will give you idea.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top