summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Bus/Horloge/HorlogeDlg.cpp89
1 files changed, 80 insertions, 9 deletions
diff --git a/Bus/Horloge/HorlogeDlg.cpp b/Bus/Horloge/HorlogeDlg.cpp
index 1bce992..b02352d 100644
--- a/Bus/Horloge/HorlogeDlg.cpp
+++ b/Bus/Horloge/HorlogeDlg.cpp
@@ -23,10 +23,11 @@ CHorlogeDlg::CHorlogeDlg(CWnd* pParent /*=NULL*/)
//{{AFX_DATA_INIT(CHorlogeDlg)
m_busnumber = _T("");
m_big_speed = FALSE;
+ m_filename = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-
+ memset( &time, 0, sizeof( time ) );
bus = NULL;
rate = 1.0;
}
@@ -41,6 +42,7 @@ void CHorlogeDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_TIME, m_Time);
DDX_Text(pDX, IDC_BUSNUMBER, m_busnumber);
DDX_Check(pDX, IDC_BIGSPEED, m_big_speed);
+ DDX_Text(pDX, IDC_FILENAME, m_filename);
//}}AFX_DATA_MAP
}
@@ -60,6 +62,9 @@ BEGIN_MESSAGE_MAP(CHorlogeDlg, CDialog)
ON_BN_CLICKED(IDC_FORW_1, OnForw1)
ON_BN_CLICKED(IDC_FORW_2, OnForw2)
ON_BN_CLICKED(IDC_FORW_5, OnForw5)
+ ON_BN_CLICKED(IDC_FILE, OnFile)
+ ON_BN_CLICKED(IDC_NORMAL_SPEED, OnNormalSpeed)
+ ON_LBN_DBLCLK(IDC_APPLIST, OnDblclkApplist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -79,10 +84,12 @@ BOOL CHorlogeDlg::OnInitDialog()
((CButton*)GetDlgItem(IDC_BACKWARD))->SetIcon(AfxGetApp()->LoadIcon(IDI_BACKWARD));
((CButton*)GetDlgItem(IDC_PAUSE))->SetIcon(AfxGetApp()->LoadIcon(IDI_PAUSE));
((CButton*)GetDlgItem(IDC_START))->SetIcon(AfxGetApp()->LoadIcon(IDI_START));
+ ((CButton*)GetDlgItem(IDC_NORMAL_SPEED))->SetIcon(AfxGetApp()->LoadIcon(IDI_NORMAL_SPEED));
m_Time.Format("%02d:%02d:%02d", 0,0,0);
m_Speed.Format("%.2f", rate );
+ m_setTime.GetTime(&time);
bus = new Ivy( "Horloge","Horloge READY",this,TRUE);
@@ -98,6 +105,7 @@ BOOL CHorlogeDlg::OnInitDialog()
bus->BindMsg("^ClockEvent Time=([0-9]+):([0-9]+):([0-9]+) Rate=([-.0-9]+) Bs=([0-9]+)", BUS_CALLBACK_OF(CHorlogeDlg, IvyClockEvent ));
bus->BindMsg("^ClockDatas Time=([0-9]+):([0-9]+):([0-9]+) Rate=([-.0-9]+) Bs=([0-9]+)", BUS_CALLBACK_OF(CHorlogeDlg, IvyClockEvent ));
+ bus->BindMsg("^FileReadEvent Type=REJEU Name=([^ ]+) StartTime=([0-9]+):([0-9]+):([0-9]+) EndTime=([0-9]+):([0-9]+):([0-9]+)", BUS_CALLBACK_OF(CHorlogeDlg, IvyFileReadEvent ));
bus->BindMsg("^rejeu READY", BUS_CALLBACK_OF(CHorlogeDlg, IvyRejeuReady));
m_busnumber = bus->GetDomain( m_busnumber );
@@ -163,6 +171,21 @@ void CHorlogeDlg::OnApplicationDisconnected(IvyApplication *app)
{
m_applist.DeleteString(m_applist.FindString(0, app->GetName()) );
}
+
+void CHorlogeDlg::OnDblclkApplist()
+{
+ CString name;
+ int sel = m_applist.GetCurSel();
+ m_applist.GetText( sel, name );
+ IvyApplication *app = bus->GetApplication( name );
+ if ( app )
+ {
+ bus->SendDieMsg(app);
+ m_applist.DeleteString( sel );
+ }
+
+}
+
void CHorlogeDlg::IvyClockEvent( IvyApplication *app, int argc, const char **argv )
{
// Ivy ClockEvent Time=10:23:45 Rate=3 Bs=0
@@ -177,6 +200,26 @@ void CHorlogeDlg::IvyClockEvent( IvyApplication *app, int argc, const char **arg
m_setTime.SetTime(&time);
UpdateData(FALSE);
}
+void CHorlogeDlg::IvyFileReadEvent( IvyApplication *app, int argc, const char **argv )
+{
+ // Ivy FileReadEvent Type=REJEU Name=/home/fcolin/asterix/EAF3534D.rej StartTime=19:57:00 EndTime=20:09:59
+ const char* name = *argv++;
+ int hh_start = atoi( *argv++ );
+ int mm_start = atoi( *argv++ );
+ int ss_start = atoi( *argv++ );
+ int hh_end = atoi( *argv++ );
+ int mm_end = atoi( *argv++ );
+ int ss_end = atoi( *argv++ );
+
+ time.wHour = hh_start;
+ time.wMinute = mm_start;
+ time.wSecond = ss_start;
+
+ m_Time.Format("%02d:%02d:%02d", time.wHour, time.wMinute, time.wSecond);
+ VERIFY(m_setTime.SetTime(&time));
+ m_filename = name;
+ UpdateData(FALSE);
+}
void CHorlogeDlg::IvyRejeuReady( IvyApplication *app, int argc, const char **argv )
{
bus->SendMsg("GetClockDatas");
@@ -196,14 +239,20 @@ void CHorlogeDlg::OnBackward()
{
rate -= 0.5;
m_Speed.Format("%.2f", rate );
- bus->SendMsg("SetClock Rate=%f",rate);
+ bus->SendMsg("SetClock Rate=%.2f",rate);
}
void CHorlogeDlg::OnForward()
{
rate += 0.5;
m_Speed.Format("%.2f", rate );
- bus->SendMsg("SetClock Rate=%f",rate);
+ bus->SendMsg("SetClock Rate=%.2f",rate);
+}
+void CHorlogeDlg::OnNormalSpeed()
+{
+ rate = 1.0;
+ m_Speed.Format("%.2f", rate );
+ bus->SendMsg("SetClock Rate=%.2f",rate);
}
@@ -218,42 +267,64 @@ void CHorlogeDlg::OnDatetimechangeSettime(NMHDR* pNMHDR, LRESULT* pResult)
void CHorlogeDlg::OnBack5()
{
- time.wMinute -= 5;
+ CTime new_time( time );
+ new_time -= CTimeSpan( 0, 0, 5, 0 );
+ new_time. GetAsSystemTime(time);
bus->SendMsg( "SetClock Time=%d:%d:%d", time.wHour, time.wMinute, time.wSecond );
m_Time.Format("%02d:%02d:%02d", time.wHour, time.wMinute, time.wSecond);
}
void CHorlogeDlg::OnBack2()
{
- time.wMinute -= 2;
+ CTime new_time( time );
+ new_time -= CTimeSpan( 0, 0, 2, 0 );
+ new_time. GetAsSystemTime(time);
bus->SendMsg( "SetClock Time=%d:%d:%d", time.wHour, time.wMinute, time.wSecond );
m_Time.Format("%02d:%02d:%02d", time.wHour, time.wMinute, time.wSecond);
}
void CHorlogeDlg::OnBack1()
{
- time.wMinute -= 1;
+ CTime new_time( time );
+ new_time -= CTimeSpan( 0, 0, 1, 0 );
+ new_time. GetAsSystemTime(time);
bus->SendMsg( "SetClock Time=%d:%d:%d", time.wHour, time.wMinute, time.wSecond );
m_Time.Format("%02d:%02d:%02d", time.wHour, time.wMinute, time.wSecond);
}
void CHorlogeDlg::OnForw1()
{
- time.wMinute += 1;
+ CTime new_time( time );
+ new_time += CTimeSpan( 0, 0, 1, 0 );
+ new_time. GetAsSystemTime(time);
bus->SendMsg( "SetClock Time=%d:%d:%d", time.wHour, time.wMinute, time.wSecond );
m_Time.Format("%02d:%02d:%02d", time.wHour, time.wMinute, time.wSecond);
}
void CHorlogeDlg::OnForw2()
{
- time.wMinute += 2;
+ CTime new_time( time );
+ new_time += CTimeSpan( 0, 0, 2, 0 );
+ new_time. GetAsSystemTime(time);
bus->SendMsg( "SetClock Time=%d:%d:%d", time.wHour, time.wMinute, time.wSecond );
m_Time.Format("%02d:%02d:%02d", time.wHour, time.wMinute, time.wSecond);
}
void CHorlogeDlg::OnForw5()
{
- time.wMinute += 5;
+ CTime new_time( time );
+ new_time += CTimeSpan( 0, 0, 5, 0 );
+ new_time. GetAsSystemTime(time);
bus->SendMsg( "SetClock Time=%d:%d:%d", time.wHour, time.wMinute, time.wSecond );
m_Time.Format("%02d:%02d:%02d", time.wHour, time.wMinute, time.wSecond);
}
+
+void CHorlogeDlg::OnFile()
+{
+ CFileDialog file(TRUE,TEXT(".rej"),NULL, OFN_FILEMUSTEXIST,"Rejeu Files (*.rej)|*.rej|All Files (*.*)|*.*||");
+ if ( file.DoModal() == IDOK )
+ {
+ bus->SendMsg( "FileRead Type=rejeu Name=%s", file.GetPathName() );
+ }
+}
+