26 #define _CRT_SECURE_NO_DEPRECATE
27 #include "../../BatchALMaSS/ALMaSS_Setup.h"
28 #include "../../Landscape/ls.h"
29 #include "../../Landscape/cropprogs/CloverGrassGrazed2.h"
49 switch ( m_ev->m_todo ) {
58 m_last_date=g_date->DayInYear(1,10);
61 m_field->SetMDates(0,0,g_date->DayInYear(25, 6));
64 m_field->SetMDates(1,0,g_date->DayInYear(25, 6));
65 m_field->SetMDates(0,1,g_date->DayInYear(1,9));
66 m_field->SetMDates(1,1,g_date->DayInYear(1,10));
76 if (m_ev->m_startday>g_date->DayInYear(1,7))
78 if (m_field->GetMDates(0,0) >=m_ev->m_startday)
80 g_msg->Warn( WARN_BUG,
"CloverGrassGrazed2::Do(): "
81 "Harvest too late for the next crop to start!!!",
"" );
85 for (
int i=0; i<noDates; i++) {
86 if(m_field->GetMDates(0,i)>=m_ev->m_startday) {
87 m_field->SetMDates(0,i,m_ev->m_startday-1);
89 if(m_field->GetMDates(1,i)>=m_ev->m_startday){
90 m_field->SetMConstants(i,0);
91 m_field->SetMDates(1,i,m_ev->m_startday-1);
97 if ( ! ( m_ev->m_first_year
100 d1 = g_date->OldDays() + g_date->DayInYear( 1,7 );
101 if (g_date->Date() < d1) {
103 g_msg->Warn( WARN_BUG,
"CloverGrassGrazed2::Do(): "
104 "Crop start attempt between 1st Jan & 1st July",
"" );
109 d1 = g_date->OldDays() + m_first_date+365;
110 if (g_date->Date() > d1) {
112 g_msg->Warn( WARN_BUG,
"CloverGrassGrazed2::Do(): "
113 "Crop start attempt after last possible start date",
120 d1 = g_date->OldDays() + g_date->DayInYear( 1, 4 );
124 if (!m_ev->m_first_year) d1 += 365;
127 m_field->SetLastSownVeg( m_field->GetVegType() );
128 d1 = g_date->OldDays() + m_first_date+365;
138 if (g_date->Date() >= d1) d1 += 365;
146 if ( m_ev->m_lock || m_farm->DoIt( 100 ))
157 if ( m_ev->m_lock || m_farm->DoIt( 30 )) {
158 if (!m_farm->FA_Slurry( m_field, 0.0,
159 g_date->DayInYear( 25, 4 ) -
160 g_date->DayInYear())) {
169 if ( m_ev->m_lock || m_farm->DoIt( 80 )) {
170 if (!m_farm->FA_NPK( m_field, 0.0,
171 g_date->DayInYear( 25, 4 ) -
172 g_date->DayInYear())) {
182 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ),
188 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15, 5 ),
194 if ( m_ev->m_lock || m_farm->DoIt( (
int) (100- ((
cfg_silage_prop.value()*40) )))) {
195 if (m_field->GetMConstants(1)==0) {
196 if (!m_farm->CattleOut( m_field, 0.0, -1)) {
197 g_msg->Warn( WARN_BUG,
"CloverGrassGrazed2::Do(): failure in 'CattleOut' execution",
"" );
202 if (!m_farm->CattleOut( m_field, 0.0, m_field->GetMDates(1,1) - g_date->DayInYear())) {
212 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,5 ),
cgg2_cut_to_silage, true );
237 if (!m_farm->CattleIsOut(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear(), m_field->GetMDates(1, 1))) {
239 if (g_date->Date() == m_field->GetMDates(1, 1)){
240 g_msg->Warn(WARN_BUG,
"CloverGrassGrazed2::Do(): failure in 'CattleIsOut' execution",
"Over-stepped the last possible date");
250 if ( m_ev->m_lock ) {
255 if (!m_farm->CutToSilage( m_field, 0.0,
256 g_date->DayInYear( 25, 6 ) -
257 g_date->DayInYear())) {
270 if ( m_ev->m_lock || m_farm->DoIt( 20 )) {
273 if (m_field->GetMConstants(1)==0) {
274 if (!m_farm->StubbleHarrowing( m_field, 0.0, -1)) {
275 g_msg->Warn( WARN_BUG,
"CloverGrassGrazed2::Do(): failure in 'StubbleHarrowing' execution",
"" );
280 if (!m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1,1) - g_date->DayInYear())) {
288 m_field->SetMDates(1,1,g_date->DayInYear()-1);
293 if ( m_ev->m_lock || m_farm->DoIt( 25 )) {
299 if (!m_farm->Water( m_field, 0.0,
300 g_date->DayInYear( 30, 5 ) -
301 g_date->DayInYear())) {
308 long newdate1 = g_date->OldDays() + g_date->DayInYear( 1,6 );
309 long newdate2 = g_date->Date() + 7;
310 if ( newdate2 > newdate1 )
317 if ( m_ev->m_lock || m_farm->DoIt( 25 )) {
323 if (!m_farm->Water( m_field, 0.0,
324 g_date->DayInYear( 15, 6 ) -
325 g_date->DayInYear())) {
336 g_msg->Warn( WARN_BUG,
"CloverGrassGrazed2::Do(): "
337 "Unknown event type! ",
"" );