Problem of candidates

Hi,

I am writing an alarmClass and a AlarmsManager class.
I got this error :

C:\arduino\arduino-0021\libraries\AlarmsManager\AlarmsManager.cpp: In constructor ‘AlarmsManager::AlarmsManager()’:
C:\arduino\arduino-0021\libraries\AlarmsManager\AlarmsManager.cpp:3: error: no matching function for call to ‘Alarm::Alarm()’
C:\arduino\arduino-0021\libraries\Alarm/Alarm.h:10: note: candidates are: Alarm::Alarm(int, int, int)
C:\arduino\arduino-0021\libraries\Alarm/Alarm.h:8: note: Alarm::Alarm(const Alarm&)

This is the header of alarm Class

#ifndef __ALARM_H__
#define __ALARM_H__


typedef void (*OnTick_t)();  // alarm callback function typedef 

class Alarm
{
      public:
            Alarm( int hours, int minutes, int seconds );
            ~Alarm();

            void set_minutes ( int pminutes );
            int get_minutes  ( );

            void set_hours   ( int phours );
            int get_hours    ( );

            void set_seconds ( int pseconds );
            int get_seconds  ( );


              void set_onTickHandler ( OnTick_t ponTickHandler );  
              OnTick_t get_onTickHandler ();  


            void set_m_dayOfWeek ( int pm_dayOfWeek );
            int get_m_dayOfWeek ();


            void set_m_day ( int pm_day );
            int get_m_day ();


            void set_m_month ( int pm_month );
            int get_m_month ();


            void set_m_year ( int pm_year ); 
            int get_m_year (); 

      private:

            int m_minutes;
            int m_hours;
            int m_seconds; 

            int m_dayOfWeek;
            int m_day;
            int m_month;
            int m_year; 

            bool m_isAllocated; 

              OnTick_t m_onTickHandler;  
};

#endif /* __ALARM_H__ */

This is the header of alarmsManager Class

#ifndef __ALARMSMANAGER_H__
#define __ALARMSMANAGER_H__

#include <inttypes.h>
#include <Alarm.h>

#define dtNBR_ALARMS 6
typedef uint8_t AlarmID;

class AlarmsManager
{
public:
      AlarmsManager();
      ~AlarmsManager();
      
private:

   // data members
   Alarm AlarmTab[dtNBR_ALARMS];
   uint8_t isCheckingAlarms;
   // methods members
   void checkingAlarms();
   AlarmID create(  int hours, int minutes, int seconds, OnTick_t onTickHandler);
};
#endif /* __ALARMSMANAGER_H__ */

This code line is not in my sources yet.

C:\arduino\arduino-0021\libraries\Alarm/Alarm.h:8: note: Alarm::Alarm(const Alarm&)

It seems like intermediate object are not well deleted by arduino env.

class AlarmsManager
{
public:
AlarmsManager(); // With no initializers

private:

// data members
Alarm AlarmTab[dtNBR_ALARMS]; // These have to have a constructor that takes no parameters

I strongly suggest that you change the Alarm constructor to take no parameters and add an initialization method (“begin” is a good name for such a method).

Ok so to understand this is due to my array ?

No. The problem is because the Alarm constructor requires parameters and you’re not providing them. When you create an AlarmsManager instance, the Alarm instances in your AlarmTab array have to initialized with parameters.

Got another problem.

CoreSystem.cpp.o:(.bss.AlarmMng+0x0): multiple definition of `AlarmMng’
AlarmsManager\AlarmsManager.cpp.o:C:\arduino\arduino-0021\libraries\AlarmsManager/AlarmsManager.cpp:34: first defined here

/*
   CoreSystem

   Manage Main Loop to control some electrical feature
   */

#include <inttypes.h>

#include <Time.h>

// niva add features
#include <Utils.h>
#include <Traces.h>
#include <PinManager.h>
#include <FunctionalTasks.h>
#include <FunctionalWrapper.h>
#include <QueueList.h>

#include <Alarm.h>
#include <AlarmsManager.h>

#include <Wire.h>
#include <LiquidCrystal.h>
#include <DS1307.h> // written by  mattt on the Arduino forum and modified by D. Sjunnesson



Traces            Tracer                   ;

/* Arduino          Lcd 2x16
 *
 * VSS              Pin 1
 * VDD              Pin 2
 * VSS              Pin 3
 * Pin 7            Pin 4
 * VSS              Pin 5
 * Pin 8            Pin 6
 * NA                  Pin 7
 * NA                  Pin 8
 * NA                  Pin 9
 * NA                  Pin 10
 * Pin 9            Pin 11
 * Pin 10           Pin 12
 * Pin 11           Pin 13
 * Pin 12           Pin 14
 * VDD              Pin 15
 * VSS              Pin 16
 *
 *
 */
LiquidCrystal     lcd(7, 8, 9, 10, 11, 12) ;
FunctionalTasks   FuncTask                 ;
PinManager        PinMng                   ;
 
// ENTREES 

//
//  SETUP
//

void setup()  { 

      // SERIAL
      Serial.begin(9600); 

      // LCD
        lcd.begin(16, 2);
        lcd.setCursor(0, 0);
        lcd.clear();
        delay(2000);

      // pass lcd to tracer and tracer to all others objects
      Tracer.setLcd(&lcd);
      FuncTask.setTracer(&Tracer);
      PinMng.setTracer(&Tracer);
      FuncTask.setPinManager(&PinMng);

      FuncTask.setRealTimeClock();   //!!! only if date is out of date

      // Bind the wrapper to FunctionalTasks p and call procedure
      FunctionalWrapper::setObj(FuncTask);

      //
    Tracer.LcdDelayPrintTopLineFromLeft("Ecran........OK");


      // CONFIGURATION
      FuncTask.ConfigPinsRelays();

    Tracer.LcdDelayPrintBottomLineFromLeft("Config Pins..OK");
        delay(600);
      FuncTask.displayRelayConfig();

      // AUTOTEST RELAIS
      FuncTask.Autotests();

      AlarmMng.alarm(10, 12, 4, 12, 0, 0, FunctionalWrapper::AlimenterLampadaireLnk);

} 

//
//  LOOP
//
void loop()  {

            FuncTask.AfficheDateEtHeure();
            AlarmMng.checkingAlarms();
}
#ifndef __ALARMSMANAGER_H__
#define __ALARMSMANAGER_H__

#include <inttypes.h>
#include <Alarm.h>

// counters of alarms things
#define NBR_ALARMS 6
#define IdInvalidAlarm 99

typedef uint8_t AlarmID;

class AlarmsManager
{
      public:
            AlarmsManager();
            ~AlarmsManager();


            void checkingAlarms();
            // alarm
            AlarmID alarm(const int year, const int month, const int day, const int hour,  const int minutes,  const int seconds, OnTick_t onTickHandler); 

      private:

            // data members
            Alarm AlarmTab[NBR_ALARMS];
            uint8_t isCheckingAlarms;


            // methods members

            // alarm creator
            AlarmID create(const int year, const int month, const int day, const int hour,  const int minutes,  const int seconds, OnTick_t onTickHandler);

};

AlarmsManager AlarmMng = AlarmsManager();
#endif /* __ALARMSMANAGER_H__ */
#include "AlarmsManager.h"            
#include "utils.h"            

AlarmsManager::AlarmsManager()
{
}

AlarmsManager::~AlarmsManager()
{
}

AlarmID AlarmsManager::create(const int year, const int month, const int day, const int hour,  const int minutes,  const int seconds, OnTick_t onTickHandler)
{
      for (uint8_t id = 0; id < NBR_ALARMS; id++)
      {
            if ( AlarmTab[id].get_m_isAllocated() == false )
            {
                  AlarmTab[id].set_m_isAllocated(true);
                  AlarmTab[id].set_hours(hour);
                  AlarmTab[id].set_minutes(minutes);
                  AlarmTab[id].set_seconds(seconds);

                  return id;
            }
      }
      return IdInvalidAlarm;
}

/**
 * 
 * Check all alarms to launch those
 *
 */
void AlarmsManager::checkingAlarms()
{
      if ( !isCheckingAlarms  )
      {
            isCheckingAlarms=true;

            for (uint8_t id = 0; id < NBR_ALARMS; id++)
            {
                  // check if years are equals
                  if ( AlarmTab[id].get_m_year() == horodatage::getYear() )
                  {
                        // check if months are equals
                        if ( AlarmTab[id].get_m_month() == horodatage::getMonth() )
                        {
                              // check if day are equals
                              if ( AlarmTab[id].get_m_day() == horodatage::getDay() )
                              {
                                    // check if hours are equals
                                    if ( AlarmTab[id].get_hours() == horodatage::getHours() )
                                    {
                                          // check if minutes are equals
                                          if ( AlarmTab[id].get_minutes() == horodatage::getMinutes() )
                                          {
                                                // check if minutes are equals
                                                if ( AlarmTab[id].get_seconds() == horodatage::getSeconds() )
                                                {
                                                      OnTick_t TickHandler = AlarmTab[id].get_onTickHandler();
                                                      if( TickHandler != NULL) {        
                                                            (*TickHandler)();     // call the handler  
                                                      }
                                                }
                                          }
                                    }
                              }
                        }
                  }
            }

            isCheckingAlarms=false;
      }
}

AlarmID AlarmsManager::alarm(const int year, const int month, const int day, const int hour,  const int minutes,  const int seconds, OnTick_t onTickHandler)
{
      return create( year,  month,  day,  hour, minutes, seconds, onTickHandler);
}

I have moved the insanciation of my AlarmManger into the sketch like that :

LiquidCrystal     lcd(7, 8, 9, 10, 11, 12) ;
FunctionalTasks   FuncTask                 ;
PinManager        PinMng                   ;
AlarmsManager AlarmMng;

// ENTREES 

//
//  SETUP
//

void setup()  {

and it relaunch the setup many times.

It is unlikely that moving where AlarmMng is created is causing the issue. It is more likely that you are trying to reference AlarmMng before setting up any alarms.