beautypg.com

Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual

Page 84

background image

CHAPTER 8 • SERIAL MESSAGE SUPPORT 83

void BuildTimeResponseMsg(void)
{
ClickMsgString message3;
ClickUtilTime now;
unsigned long u32tmp;

ClickUtilGetTime(&now);
u32tmp = (unsigned long)now.Year;
ClickMsgWriteVar(“year2”,&u32tmp);
u32tmp = (unsigned long)now.Month;
ClickMsgWriteVar(“month2”,&u32tmp);
u32tmp = (unsigned long)now.DayOfMonth;
ClickMsgWriteVar(“day2”,&u32tmp);
u32tmp = (unsigned long)now.Hour;
ClickMsgWriteVar(“hour2”,&u32tmp);
u32tmp = (unsigned long)now.Minute;
ClickMsgWriteVar(“minute2”,&u32tmp);
u32tmp = (unsigned long)now.Second;
ClickMsgWriteVar(“sec2”,&u32tmp);
u32tmp = (unsigned long)now.MSec;
ClickMsgWriteVar(“ms2”,&u32tmp);
}

void SetTime(int port)
{
ClickUtilTime newTime;
unsigned long u32tmp;

ClickMsgReadVar(“year1”,&u32tmp);
newTime.Year = (int)u32tmp;
ClickMsgReadVar(“month1”,&u32tmp);
newTime.Month = (unsigned char)u32tmp;
ClickMsgReadVar(“day1”,&u32tmp);
newTime.DayOfMonth = (unsigned char)u32tmp;
ClickMsgReadVar(“hour1”,&u32tmp);
newTime.Hour = (unsigned char)u32tmp;
ClickMsgReadVar(“minute1”,&u32tmp);
newTime.Minute = (unsigned char)u32tmp;