HI, I am working a program for an Aquarium which contains controls for lights and a electronic fish feeder. I have found a way to get the system time but I do not have the desired result. [1] I want to be able to set the system time during run time and have the time run during run time ( my program shows the current time and I can't set the time during run time).
[2] I am trying to implement a timer that will check itself against the system clock within my fish timer and light timer functions. Help will be greatly appreciated, Thanks
#include <windows.h>
#include <stdlib.h>
#include <iostream>
#include <time.h>
using namespace std;
class ControlPanel {
public:
ControlPanel();
~ControlPanel() {};
void SetFeedFish(bool);
bool GetFeedFish();
void SetLightSwitch(bool);
bool GetLightSwitch();
void Time();
void FishTimer();
void LightTimer();
private:
bool FeedFish;
bool LightSwitch;
};
ControlPanel::ControlPanel()
{
FeedFish = false;
LightSwitch = false;
}
void ControlPanel::FishTimer() // Not sure how to implement input
{
}
/*
void ControlPanel::LightTimer() //Ditto
{
}
*/
void ControlPanel::Time() // Returns Time of PC clock
{
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
time ( &rawtime );
timeinfo = localtime ( &rawtime );
strftime (buffer,80,"Now is %I:%M:%S%p.",timeinfo);
puts (buffer);
}
void ControlPanel:SetFeedFish( bool AllFish)
{
FeedFish = AllFish;
}
bool ControlPanel::GetFeedFish()
{
return FeedFish;
}
void ControlPanel:SetLightSwitch(bool AllLights)
{
LightSwitch = AllLights;
}
bool ControlPanel::GetLightSwitch()
{
return LightSwitch;
}