WinterWheat Class Reference

WinterWheat class
. More...

#include <WinterWheat.H>

List of all members.

Public Member Functions

virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 The one and only method for a crop management plan. All farm actions go through here.
 WinterWheat ()


Detailed Description

WinterWheat class
.

See WinterWheat.h::WinterWheatToDo for a complete list of all possible events triggered codes by the winter wheat management plan. When triggered these events are handled by Farm and are available as information for other objects such as animal and bird models.


Constructor & Destructor Documentation

WinterWheat::WinterWheat (  )  [inline]

References Crop::m_first_date.

00118    {
00119                 // When we start it off, the first possible date for a farm operation is 1st October
00120                 // This information is used by other crops when they decide how much post processing of 
00121                 // the management is allowed after harvest before the next crop starts.
00122                 m_first_date=g_date->DayInYear( 1,10 );
00123    }


Member Function Documentation

bool WinterWheat::Do ( Farm a_farm,
LE *  a_field,
FarmEvent a_ev 
) [virtual]

The one and only method for a crop management plan. All farm actions go through here.

Called every time something is done to the crop by the farmer in the first instance it is always called with m_ev->todo set to start, but susequently will be called whenever the farmer wants to carry out a new operation.
This method details all the management and relationships between operations necessary to grow and ALMaSS crop - in this case conventional winter wheat.

Reimplemented from Crop.

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnRoll(), Farm::AutumnSow(), cfg_fungi_app_prop, cfg_greg_app_prop, cfg_herbi_app_prop, cfg_ins_app_prop, cfg_WinterWheat_SkScrapes(), Farm::DeepPlough(), Farm::DoIt(), Farm::FA_Manure(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_ManganeseSulphate(), Farm::FP_NPK(), Farm::FP_Slurry(), Farm::FungicideTreat(), Farm::GrowthRegulator(), Farm::Harvest(), Farm::HayBailing(), Farm::HayTurning(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_first_date, FarmEvent::m_first_year, FarmEvent::m_lock, FarmEvent::m_startday, FarmEvent::m_todo, Crop::SimpleEvent(), Farm::SpringRoll(), Farm::StrawChopping(), Farm::Strigling(), Farm::StubbleHarrowing(), Farm::Water(), ww_autumn_harrow, ww_autumn_plough, WW_AUTUMN_PLOUGH, ww_autumn_roll, ww_autumn_sow, ww_ferti_p1, ww_ferti_p2, ww_ferti_p3, ww_ferti_p4, ww_ferti_p5, ww_ferti_s1, ww_ferti_s2, ww_ferti_s3, ww_ferti_s4, ww_ferti_s5, ww_fungicide, ww_fungicide2, ww_GR, ww_grubning, ww_harvest, ww_hay_baling, ww_hay_turning, ww_herbicide1, ww_herbicide2, ww_insecticide1, ww_insecticide2, ww_insecticide3, ww_spring_roll, ww_start, ww_straw_chopping, ww_strigling1, ww_strigling2, ww_stubble_harrow1, ww_stubble_harrow2, ww_water1, and ww_water2.

Referenced by Farm::LeSwitch().

00071 {
00072   m_farm  = a_farm;
00073   m_field = a_field;
00074   m_ev    = a_ev;
00075   // The boolean value done indicates when we are totally finished with this plan
00076   bool done = false;
00077   // Depending what event has occured jump to the correct bit of code e.g. for ww_start jump to line 67 below
00078   switch ( m_ev->m_todo )
00079   {
00080     case ww_start:
00081                 { // This is just to hold a local variable in scope and prevent compiler errors
00082                         // ww_start just sets up all the starting conditions and reference dates that are needed to start a ww 
00083                         // crop off
00084                         WW_AUTUMN_PLOUGH         = false;
00085                         // Record whether skylark scrapes are present and adjust flag accordingly
00086                         if (cfg_WinterWheat_SkScrapes.value()) {
00087                                 a_field->m_skylarkscrapes=true; 
00088                         } else {
00089                                 a_field->m_skylarkscrapes=false;
00090                         }
00091                         // Set up the date management stuff
00092                         // The next bit of code just allows for altering dates after harvest if it is necessary
00093                         // to allow for a crop which starts its management early.
00094 
00095                         // 5 start and stop dates for all events after harvest for this crop
00096                         int noDates=5;
00097                         m_field->SetMDates(0,0,g_date->DayInYear(20,8));
00098                         // Determined by harvest date - used to see if at all possible
00099                         m_field->SetMDates(1,0,g_date->DayInYear(20,8));
00100                         m_field->SetMDates(0,1,0); // Subbleharrow start
00101                         m_field->SetMDates(1,1,g_date->DayInYear(20,8));
00102                         m_field->SetMDates(0,2,g_date->DayInYear(5,8));
00103                         m_field->SetMDates(1,2,g_date->DayInYear(25,8));
00104                         m_field->SetMDates(0,3,g_date->DayInYear(10,8));
00105                         m_field->SetMDates(1,3,g_date->DayInYear(15,9));
00106                         m_field->SetMDates(0,4,g_date->DayInYear(15,8));
00107                         m_field->SetMDates(1,4,g_date->DayInYear(15,10));
00108                         // Can be up to 10 of these. If the shortening code is triggered
00109                         // then these will be reduced in value to 0
00110                         m_field->SetMConstants(0,1);
00111                         // Check the next crop for early start, unless it is a spring crop
00112                         // in which case we ASSUME that no checking is necessary!!!!
00113                         // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
00114                         if (m_ev->m_startday>g_date->DayInYear(1,7)) {
00115                                 if (m_field->GetMDates(0,0) >=m_ev->m_startday)
00116                                 {
00117                                   g_msg->Warn( WARN_BUG, "WinterWheat::Do(): ","Harvest too late for the next crop to start!!!" );
00118                                   exit( 1 );
00119                                 }
00120                                 // Now fix any late finishing problems
00121                                 bool toggle=false;
00122                                 for (int i=0; i<noDates; i++) {
00123                                   if  (m_field->GetMDates(0,i)>=m_ev->m_startday) {
00124                                         toggle=true;
00125                                         m_field->SetMDates(0,i,m_ev->m_startday-1);
00126                                   }
00127                                   if  (m_field->GetMDates(1,i)>=m_ev->m_startday){
00128                                         toggle=true;
00129                                         m_field->SetMDates(1,i,m_ev->m_startday-1);
00130                                   }
00131                                 }
00132                                 if (toggle) for (int i=0; i<10; i++) m_field->SetMConstants(i,0);
00133                         }
00134                         // Now no operations can be timed after the start of the next crop.
00135                         int d1;
00136                         if ( ! m_ev->m_first_year ) {
00137                                 // Are we before July 1st?
00138                                 d1 = g_date->OldDays() + g_date->DayInYear( 1,7 );
00139                                 if (g_date->Date() < d1 ) {
00140                                 // Yes, too early. We assumme this is because the last crop was late
00141                                 printf ("Poly: %d\n", m_field->GetPoly());
00142                                   g_msg->Warn( WARN_BUG, "WinterWheat::Do(): ","Crop start attempt between 1st Jan & 1st July" );
00143                                   exit( 1 );
00144                                 }
00145                                 else {
00146                                          d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
00147                                          if (g_date->Date() > d1) {
00148                                          // Yes too late - should not happen - raise an error
00149                                          g_msg->Warn( WARN_BUG, "WinterWheat::Do(): ", "Crop start attempt after last possible start date" );
00150                                          exit( 1 );
00151                                    }
00152                                 }
00153                         }
00154                         else {
00155                                 // Is the first year
00156                                 // Some special code to cope with that first start-up year in ALMaSS - ignore for all practical purposes
00157                                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 ), ww_spring_roll, false );
00158                                 break;
00159                         }
00160                         // End single block date checking code. Please see next line comment as well.
00161                         // Reinit d1 to first possible starting date.
00162                         d1 = g_date->OldDays() + g_date->DayInYear( 21,8 );
00163                         // OK, let's go.
00164                         // Here we queue up the first event - this differs depending on whether we have a
00165                         // stock or arable farmer
00166                         if (m_farm->IsStockFarmer()) { // StockFarmer
00167                                 SimpleEvent( d1, ww_ferti_s1, false );
00168                         }
00169                         else SimpleEvent( d1, ww_ferti_p1, false ); 
00170                 }
00171                 break;
00172         // This is the first real farm operation
00173     case ww_ferti_p1:
00174                 // Unless we are forced to do this (probably because we tried once and failed due to bad weather)
00175                 // then 10% of all threads that reach here will attempt to do ww_feri_p1
00176                 if ( m_ev->m_lock || m_farm->DoIt( 10 ))
00177                 {
00178                         // Calls the FP_Slurry application with the number of days after 1,10 as a parameter
00179                         // the FP_Slurry routine will attempt to apply slurry on a probabilistic basis up to 1,10 when
00180                         // the operation will be forced
00181                         // Many other constraints can be added to the FP_Slurry, e.g. temperature might have to be >0 degrees C
00182                         // Other operations need low wind speed (e.g. spraying insecticide). These differ for each operation
00183                         if (!m_farm->FP_Slurry( m_field, 0.0, g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
00184                                 // If we don't suceed on the first try, then try and try again (until 1/10 when we will suceed)
00185                                 SimpleEvent( g_date->Date() + 1, ww_ferti_p1, true );
00186                                 break;
00187                         }
00188                 }
00189                 // Queue up the next event -in this case autumn ploughing
00190                 SimpleEvent( g_date->Date(),ww_autumn_plough, false );
00191                 break;
00192         case ww_ferti_s1:
00193             if (!m_farm->FA_Slurry( m_field, 0.0, g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
00194                   SimpleEvent( g_date->Date() + 1, ww_ferti_s1, true );
00195                   break;
00196                 }
00197                 // This may cause two applications of fertilizer in one day...which is OK because one is Slurry and one Manure
00198                 SimpleEvent( g_date->Date(),ww_ferti_s2, false );
00199                 break;
00200         case ww_ferti_s2:
00201                 if ( m_ev->m_lock || m_farm->DoIt( 10 ))
00202                 {
00203                   if (!m_farm->FA_Manure( m_field, 0.0,
00204                            g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
00205                         SimpleEvent( g_date->Date() + 1, ww_ferti_s2, true );
00206                         break;
00207                   }
00208                 }
00209                 SimpleEvent( g_date->Date(),ww_autumn_plough, false );
00210                 break;
00211         case ww_autumn_plough:
00212                 // Almost all will autumn plough, but a few will get away with non-inversion
00213                 if ( m_ev->m_lock || m_farm->DoIt( 95 ))
00214                 {
00215                   if (!m_farm->AutumnPlough( m_field, 0.0,
00216                            g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
00217                         SimpleEvent( g_date->Date() + 1, ww_autumn_plough, true );
00218                         break;
00219                   }
00220                   else
00221                   {
00222                           // 95% of farmers will do this, but the other 5% won't so we need to remember whether 
00223                           // we are in one or the other group
00224                         WW_AUTUMN_PLOUGH=true;
00225                         // Queue up the next event
00226                         SimpleEvent( g_date->Date()+1,ww_autumn_harrow, false );
00227                         break;
00228                   }
00229                 }
00230                 SimpleEvent( g_date->Date()+1,ww_stubble_harrow1, false );
00231                 break;
00232         case ww_autumn_harrow:
00233                 if (!m_farm->AutumnHarrow( m_field, 0.0,
00234                            g_date->DayInYear( 10,10 ) - g_date->DayInYear())) {
00235                   SimpleEvent( g_date->Date() + 1, ww_autumn_harrow, true );
00236                   break;
00237                 }
00238                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,9 ),
00239                                    ww_autumn_sow, false );
00240                 break;
00241         case ww_stubble_harrow1:
00242                 if (!m_farm->StubbleHarrowing( m_field, 0.0,
00243                            g_date->DayInYear( 10,10 ) - g_date->DayInYear())) {
00244                   SimpleEvent( g_date->Date() + 1, ww_stubble_harrow1, true );
00245                   break;
00246                 }
00247                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,9 ),
00248                                    ww_autumn_sow, false );
00249                 break;
00250         case ww_autumn_sow:
00251                 if (!m_farm->AutumnSow( m_field, 0.0,
00252                            g_date->DayInYear( 20,10 ) - g_date->DayInYear())) {
00253                   SimpleEvent( g_date->Date() + 1, ww_autumn_sow, true );
00254                   break;
00255                 }
00256                 SimpleEvent( g_date->Date() + 1, ww_autumn_roll, false );
00257                 break;
00258         case ww_autumn_roll:
00259                 // If they did plough, then 5% will also do an autumn rolling
00260                 if (( m_ev->m_lock || m_farm->DoIt( 5 ))&& (WW_AUTUMN_PLOUGH))
00261                 {
00262                   if (!m_farm->AutumnRoll( m_field, 0.0,
00263                            g_date->DayInYear( 27,10 ) - g_date->DayInYear())) {
00264                         SimpleEvent( g_date->Date() + 1, ww_autumn_roll, true );
00265                         break;
00266                   }
00267                 }
00268                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,9 ),
00269                                                   ww_ferti_p2, false );
00270                 break;
00271                 // Plant farmers start here.
00272         case ww_ferti_p2:
00273                 if (( m_ev->m_lock || m_farm->DoIt( 20 )) && (!m_farm->IsStockFarmer()))
00274                 {
00275                   if ( m_field->GetVegBiomass()>0)
00276                   //only apply this when there has been a bit of growth
00277                   {
00278                         if (!m_farm->FP_ManganeseSulphate( m_field, 0.0,
00279                            g_date->DayInYear( 30,10 ) - g_date->DayInYear()))
00280                         {
00281                           SimpleEvent( g_date->Date() + 1, ww_ferti_p2, true );
00282                           break;
00283                         }
00284                   }
00285                 }
00286                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,9 ),
00287                                                   ww_herbicide1, false );
00288                 break;
00289         case ww_herbicide1: // The first of the pesticide managements. NB these are externally scalable
00290                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( 100*cfg_herbi_app_prop.value() )))
00291                 {
00292                   if (!m_farm->HerbicideTreat( m_field, 0.0,
00293                                  g_date->DayInYear( 5,10 ) - g_date->DayInYear())) {
00294                         SimpleEvent( g_date->Date() + 1, ww_herbicide1, true );
00295                         break;
00296                   }
00297                 }
00298                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 )+365,
00299                                  ww_spring_roll, false );
00300                 break;
00301         case ww_spring_roll:
00302                 if ( m_ev->m_lock || m_farm->DoIt( 5 ))
00303                 {
00304                   if (!m_farm->SpringRoll( m_field, 0.0,
00305                            g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
00306                         SimpleEvent( g_date->Date() + 1, ww_spring_roll, true );
00307                         break;
00308                   }
00309                 }
00310                 // Here we split the main thread in to depending on what fertilizer the farmer will use
00311                 // these rejoin other later on.
00312                 if (m_farm->IsStockFarmer()) // StockFarmer
00313                 {
00314                   SimpleEvent( g_date->Date() + 1, ww_ferti_s3, false );
00315                   SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,4 ), ww_ferti_s4, false );
00316                 }
00317                 else SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,3 ),ww_ferti_p3, false );
00318                 // Here we see an example of setting up parallel threads
00319                 // None of these are the main thread which will lead to the termination of the plan - they 
00320                 // just run along until they peter out e.g. ww_herbicide2
00321                 // All paths through the plan need the next threads
00322                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,4 ),
00323                                  ww_herbicide2, false );
00324                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,4 ),
00325                                  ww_GR, false );
00326                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,4 ),
00327                                  ww_fungicide, false );
00328                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ),
00329                                  ww_insecticide1, false );
00330                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,4 ),
00331                                  ww_strigling1, false );
00332                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ),
00333                                  ww_water1, false );
00334                 break;
00335         case ww_herbicide2:
00336                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( (int) ( 100*cfg_herbi_app_prop.value() )))) // was 40
00337                 {
00338                   if (!m_farm->HerbicideTreat( m_field, 0.0,
00339                                  g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
00340                         SimpleEvent( g_date->Date() + 1, ww_herbicide2, true );
00341                         break;
00342                   }
00343                 }
00344                 // End of thread
00345                 break;
00346         case ww_GR:
00347                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( 15*cfg_greg_app_prop.value() )))
00348                 {
00349                   if (!m_farm->GrowthRegulator( m_field, 0.0,
00350                                  g_date->DayInYear( 10,5 ) - g_date->DayInYear())) {
00351                         SimpleEvent( g_date->Date() + 1, ww_GR, true );
00352                         break;
00353                   }
00354                 }
00355                 // End of thread
00356                 break;
00357         case ww_fungicide:
00358                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( 70*cfg_fungi_app_prop.value()) ))
00359                 {
00360                   if (!m_farm->FungicideTreat( m_field, 0.0,
00361                                  g_date->DayInYear( 10,5 ) - g_date->DayInYear())) {
00362                         SimpleEvent( g_date->Date() + 1, ww_fungicide, true );
00363                         break;
00364                   }
00365                 }
00366                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,5 ),ww_fungicide2, false );
00367                 break;
00368 
00369         case ww_fungicide2:
00370                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( 50*cfg_fungi_app_prop.value()) ))
00371                 {
00372                   if (!m_farm->FungicideTreat( m_field, 0.0,
00373                                  g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
00374                         SimpleEvent( g_date->Date() + 1, ww_fungicide2, true );
00375                         break;
00376                   }
00377                 }
00378                 // End of thread
00379                 break;
00380                 // Note that for special pesticide cases this code would be de-defined to call another specific spraying event instead of InsecticideTreat() which is a generic function.
00381         case ww_insecticide1:
00382                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( 16*cfg_ins_app_prop.value() )))
00383                 {
00384                   if (!m_farm->InsecticideTreat( m_field, 0.0,g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
00385                         SimpleEvent( g_date->Date() + 1, ww_insecticide1, true );
00386                         break;
00387                   }
00388                   else {
00389                           SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,6 ),ww_insecticide2, false );
00390                           break;
00391                         }
00392                 }
00393                 break;
00394         case ww_insecticide2:
00395                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( 33*cfg_ins_app_prop.value() )))
00396                 {
00397                   if (!m_farm->InsecticideTreat( m_field, 0.0, g_date->DayInYear( 10,6 ) - g_date->DayInYear())) {
00398                         SimpleEvent( g_date->Date() + 1, ww_insecticide2, true );
00399                         break;
00400                   }
00401                   else {
00402                         if ((g_date->Date()+7)<( g_date->OldDays() + g_date->DayInYear( 15,6 )))
00403                           SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,6 ), ww_insecticide3, false );
00404                         else SimpleEvent( g_date->Date()+7, ww_insecticide3, false );
00405                         break;
00406                   }
00407                 }
00408         break;
00409         case ww_insecticide3:
00410                 if ( m_ev->m_lock || m_farm->DoIt( (int) ( 67*cfg_ins_app_prop.value() )))
00411                 {
00412                   if (!m_farm->InsecticideTreat( m_field, 0.0,g_date->DayInYear( 30,6 ) - g_date->DayInYear())) {
00413                         SimpleEvent( g_date->Date() + 1, ww_insecticide3, true );
00414                         break;
00415                   }
00416                 }
00417                 // End of thread
00418                 break;
00419         case ww_strigling1:
00420                 if ( m_ev->m_lock || m_farm->DoIt( 5 ))
00421                 {
00422                   if (!m_farm->Strigling( m_field, 0.0,
00423                                  g_date->DayInYear( 25,4 ) - g_date->DayInYear())) {
00424                         SimpleEvent( g_date->Date() + 1, ww_strigling1, true );
00425                         break;
00426                   }
00427                   else {
00428                         if ((g_date->Date()+7)<( g_date->OldDays() + g_date->DayInYear( 15,6 )))
00429                                   SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,4),
00430                                                    ww_strigling2, false );
00431                         else SimpleEvent( g_date->Date()+7,ww_strigling2, false );
00432                   }
00433                 }
00434                 break;
00435         case ww_strigling2:
00436           if (!m_farm->Strigling( m_field, 0.0,g_date->DayInYear( 5,5 ) - g_date->DayInYear())) {
00437                 SimpleEvent( g_date->Date() + 1, ww_strigling2, true );
00438                 break;
00439           }
00440           // End of thread
00441           break;
00442         case ww_water1:
00443                 if ( m_ev->m_lock || m_farm->DoIt( 10 )) // **CJT** Soil type 1-4 only
00444                 {
00445                   if (!m_farm->Water( m_field, 0.0,g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
00446                         SimpleEvent( g_date->Date() + 1, ww_water1, true );
00447                         break;
00448                   }
00449                   else
00450                         if ((g_date->Date()+5)<( g_date->OldDays() + g_date->DayInYear( 2,5 )))
00451                                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 2,5 ),ww_water2, false );
00452                         else SimpleEvent( g_date->Date()+5, ww_water2, false );
00453                 }
00454                 break;
00455         case ww_water2:
00456                 if (!m_farm->Water( m_field, 0.0, g_date->DayInYear( 1,6 ) - g_date->DayInYear())) {
00457                   SimpleEvent( g_date->Date() + 1, ww_water2, true );
00458                   break;
00459                 }
00460                 // End of thread
00461                 break;
00462         case ww_ferti_p3:
00463                 if (!m_farm->FP_NPK( m_field, 0.0,
00464                          g_date->DayInYear( 15,4 ) - g_date->DayInYear())) {
00465                   SimpleEvent( g_date->Date() + 1, ww_ferti_p3, true );
00466                   break;
00467                 }
00468 
00469                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,4 ), ww_ferti_p4, false );
00470                 SimpleEvent( g_date->OldDays() + g_date->DayInYear(  1,4 ), ww_ferti_p5, false );
00471                 break;
00472         case ww_ferti_p4:
00473                 if ( m_ev->m_lock || m_farm->DoIt( 50 ))
00474                 {
00475                   if (!m_farm->FP_NPK( m_field, 0.0, g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
00476                         SimpleEvent( g_date->Date() + 1, ww_ferti_p4, true );
00477                         break;
00478                   }
00479                 }
00480                 // The Main thread
00481                 // The Main thread - this will leads to harvest, whilst all the others stop before this point
00482                 // This thread is only for arable farmers whereas you'll see below the other forks for stock farmers
00483                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,8 ), ww_harvest, false );
00484                 break;
00485         case ww_ferti_p5:
00486                 if ( m_ev->m_lock || m_farm->DoIt( 20 ))
00487                 {
00488                   if (!m_farm->FP_ManganeseSulphate( m_field, 0.0, g_date->DayInYear( 5,5 ) - g_date->DayInYear())) {
00489                         SimpleEvent( g_date->Date() + 1, ww_ferti_p5, true );
00490                         break;
00491                   }
00492                 }
00493                 break;
00494         case ww_ferti_s3:
00495                 if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
00496                   SimpleEvent( g_date->Date() + 1, ww_ferti_s3, true );
00497                   break;
00498                 }
00499                 // The Main thread - this will leads to harvest, whilst all the others stop before this point
00500                 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,8 ), ww_harvest, false );
00501                 break;
00502         case ww_ferti_s4:
00503                 if ( m_ev->m_lock || m_farm->DoIt( 75 ))
00504                 {
00505                   if (!m_farm->FA_NPK( m_field, 0.0, g_date->DayInYear( 20,4 ) - g_date->DayInYear())) {
00506                         SimpleEvent( g_date->Date() + 1, ww_ferti_s4, true );
00507                         break;
00508                   }
00509                   SimpleEvent( g_date->OldDays() + g_date->DayInYear( 21,4 ), ww_ferti_s5, false );
00510                 }
00511                 break;
00512         case ww_ferti_s5:
00513                 if ( m_ev->m_lock || m_farm->DoIt( 40 ))
00514                 {
00515                   if (!m_farm->FA_NPK( m_field, 0.0, g_date->DayInYear( 1,5 ) - g_date->DayInYear())) {
00516                         SimpleEvent( g_date->Date() + 1, ww_ferti_s5, true );
00517                         break;
00518                   }
00519                 }
00520                 break;
00521         case ww_harvest:
00522                 if (!m_farm->Harvest( m_field, 0.0, g_date->DayInYear( 20,8 ) - g_date->DayInYear()))
00523                 {
00524                         SimpleEvent( g_date->Date() + 1, ww_harvest, true );
00525                         break;
00526                 }
00527                 SimpleEvent( g_date->Date(), ww_straw_chopping, false );
00528                 break;
00529         case ww_straw_chopping:
00530                 if ( m_ev->m_lock || m_farm->DoIt( 75 ))
00531                 {
00532                   if (!m_farm->StrawChopping( m_field, 0.0, m_field->GetMDates(1,0) - g_date->DayInYear())) {
00533                         SimpleEvent( g_date->Date() + 1, ww_straw_chopping, true );
00534                         break;
00535                   }
00536                   else {
00537                           SimpleEvent( g_date->Date()+m_field->GetMConstants(0), ww_stubble_harrow2, false );
00538                   }
00539                 }
00540                 else {
00541                   SimpleEvent( g_date->Date()+m_field->GetMConstants(0), ww_hay_turning, false );
00542                 }
00543                 break;
00544         case ww_hay_turning:
00545                 if ( m_ev->m_lock || m_farm->DoIt( 5 ))
00546                 {
00547                   if (!m_farm->HayTurning( m_field, 0.0, m_field->GetMDates(1,1) - g_date->DayInYear())) {
00548                         SimpleEvent( g_date->Date() + 1, ww_hay_turning, true );
00549                         break;
00550                   }
00551                 }
00552                 SimpleEvent( g_date->OldDays() + m_field->GetMDates(0,2), ww_hay_baling, false );
00553                 break;
00554         case ww_hay_baling:
00555                 if (!m_farm->HayBailing( m_field, 0.0, m_field->GetMDates(1,2) - g_date->DayInYear())) {
00556                   SimpleEvent( g_date->Date() + 1, ww_hay_baling, true );
00557                   break;
00558                 }
00559                 SimpleEvent( g_date->OldDays() + m_field->GetMDates(0,3), ww_stubble_harrow2, false );
00560                 break;
00561         case ww_stubble_harrow2:
00562                 if ( m_ev->m_lock || m_farm->DoIt( 65 ))
00563                 {
00564                   if (!m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1,3) - g_date->DayInYear())) {
00565                         SimpleEvent( g_date->Date() + 1, ww_stubble_harrow2, true );
00566                         break;
00567                   }
00568                 }
00569                 SimpleEvent( g_date->OldDays() + m_field->GetMDates(0,4), ww_grubning, false );
00570                 break;
00571         case ww_grubning:
00572                 if ( m_ev->m_lock || m_farm->DoIt( 10 )) {
00573                   if (!m_farm->DeepPlough( m_field, 0.0, m_field->GetMDates(1,4) - g_date->DayInYear())) {
00574                         SimpleEvent( g_date->Date() + 1, ww_grubning, true );
00575                         break;
00576                   }
00577                 }
00578                 done=true;
00579                 // So we are done, and somewhere else the farmer will queue up the start event of the next crop
00580                 // END OF MAIN THREAD
00581                 break;
00582         default:
00583                 g_msg->Warn( WARN_BUG, "WinterWheat::Do(): "
00584                          "Unknown event type! ", "" );
00585                 exit( 1 );
00586         }
00587     return done;
00588 }


The documentation for this class was generated from the following files:


WinterWheat Class Reference, 1.0