Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a program that works, but I'm building a glitch filter for method_6, and when I get it working will do the same for method_7.
I'm getting an error No overload for Method_6 not sure whats wrong or how to fix it
any help would be appreciated
Heres the code its a bit long

Tnx

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace Hydro
{
    public class Program
    {
        public const int SecondMs = 1000;
        public const int MinuteMs = 60 * SecondMs;
        public const int HourMs = 60 * MinuteMs;
        public const int DayMs = 24 * HourMs;
        public const int WeekMs = 7 * DayMs;

        private static bool method_state_6, method_state_7;



        static InterruptPort phcontroller = new InterruptPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);

        static InterruptPort nutcontroller = new InterruptPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);

        static DateTime Button1LastPushed;


        static OutputPort ph = new OutputPort(Pins.GPIO_PIN_D2, true);
        static OutputPort b = new OutputPort(Pins.GPIO_PIN_D3, true);

        static OutputPort a = new OutputPort(Pins.GPIO_PIN_D4, true);
        static OutputPort drain = new OutputPort(Pins.GPIO_PIN_D5, true);
        static OutputPort solenoid = new OutputPort(Pins.GPIO_PIN_D6, true);
        static OutputPort heater = new OutputPort(Pins.GPIO_PIN_D7, true);


        static OutputPort led = new OutputPort(Pins.GPIO_PIN_D11, true);
        static OutputPort FloodDrain = new OutputPort(Pins.GPIO_PIN_D8, true);



        public static void Main()
        {
            phcontroller.OnInterrupt += Method_6;
            // ... main loop


            try
            {
                Thread led_proc = new Thread(new ThreadStart(turn_led));
                led_proc.Start();
                while (true)
                {

                    Thread FloodDrain_proc = new Thread(new ThreadStart(turn_FloodDrain));
                    FloodDrain_proc.Start();
                    while (true)
                    {

                        Method_1();
                        call2_5();
                        call6_8();
                        Method_9();
                        Thread.Sleep(10000);
                    }

                }
            }

            catch
            {
                //Something has gone wrong; reset to a safe condition
            }
        }



        static void turn_led() //turn led for 16 hr and off for 8hr in loop
        {
            while (true)
            {
                led.Write(false);
                Thread.Sleep(HourMs * 12);
                led.Write(true);
                Thread.Sleep(HourMs * 12);
            }
        }
        static void turn_FloodDrain() //turn Flood and Drain for 1 hr and off loop
        {
            while (true)
            {
                FloodDrain.Write(false);
                Thread.Sleep(MinuteMs * 30);
                FloodDrain.Write(true);
                Thread.Sleep(HourMs * 1);
            }
        }

        public static void call2_5()
        {
            Thread t2 = new Thread(new ThreadStart(Method_2));
            t2.Start();
            Thread t3 = new Thread(new ThreadStart(Method_3));
            t3.Start();
            Thread t4 = new Thread(new ThreadStart(Method_4));
            t4.Start();
            Thread t5 = new Thread(new ThreadStart(Method_5));
            t5.Start();
            #region Wait for finishing 2-5 methods
            t2.Join();
            t3.Join();
            t4.Join();
            t5.Join();
            #endregion
        }
        static void call6_8()
        {
            method_state_6 = method_state_7 = true;
            Thread t6 = new Thread(new ThreadStart(Method_6));
            t6.Start();
            Thread t7 = new Thread(new ThreadStart(Method_7));
            t7.Start();
            Thread t8 = new Thread(new ThreadStart(Method_8));
            t8.Start();

            // wait for Method_8 finishing
            t8.Join();
            method_state_6 = method_state_7 = false;

        }
        public static void Method_1()
        {
            drain.Write(false);
            Thread.Sleep(16 * MinuteMs);
            drain.Write(true);
        }
        public static void Method_2()
        {
            solenoid.Write(false);
            Thread.Sleep(16 * MinuteMs);
            solenoid.Write(true);
        }
        public static void Method_3()
        {
            a.Write(false);
            Thread.Sleep(182 * SecondMs);
            a.Write(true);
        }
        public static void Method_4()
        {
            b.Write(false);
            Thread.Sleep(100 * SecondMs);
            b.Write(true);
        }
        public static void Method_5()
        {
            ph.Write(false);
            Thread.Sleep(5 * SecondMs);
            ph.Write(true);
        }

        private static void Method_6(uint data1, uint data2, DateTime time)
        {
            // glitch filter. events within 50 milliseconds of the first event are discarded
            if (Button1LastPushed.AddMilliseconds(50) > time)
                return;
            //         Debug.Print("Button 1 Interrupt");
            Button1LastPushed = time;
            ph.Write(false);
            Thread.Sleep(2000);
            ph.Write(true);
            Thread.Sleep(5 * MinuteMs);
        }


        public static void Method_7()
        {
            Thread.Sleep(5 * MinuteMs);
            while ((!method_state_7) && (!nutcontroller.Read()))  //nutcontroller is just a relay that closes when needed
            {
                a.Write(false);
                Thread.Sleep(5454);
                a.Write(true);
                b.Write(false);
                Thread.Sleep(3000);
                b.Write(true);
                Thread.Sleep(5 * MinuteMs);
            }
        }


        public static void Method_8()
        {
            heater.Write(false);
            for (int i = 0; i < 14; i++)
            {
                Thread.Sleep(1 * DayMs);
                solenoid.Write(false);
                Thread.Sleep(20 * SecondMs);
                solenoid.Write(true);


            }
            heater.Write(true);
        }

        public static void Method_9()
        {
            drain.Write(false);
            Thread.Sleep(16 * MinuteMs);
            drain.Write(true);
            solenoid.Write(false);
            Thread.Sleep(16 * MinuteMs);
            solenoid.Write(true);
            Thread.Sleep(1 * MinuteMs);

        }

    }
}
Posted
Comments
ZurdoDev 7-Dec-12 10:46am    
Method_6 requires parameters but I did not see you calling it with params.

Your method names suck as they don't scribed what the method does at all.

You'll get a "No overload could be found ..." message if, when call Method_6, you either don't supply the correct number of arguments or you supply arguments of the wrong type.

In your case, you used Method_6 as an event handler that doesn't take any arguments AND it's the target of a ThreadStart, which also doesn't take any arguments, and when you declared Method_6, you supplied them.
 
Share this answer
 
Assuming the error is No overload for Method_6 takes 0 arguments ...

You should be using ParameterizedThreadStart for this method.

have a look at http://www.dotnetperls.com/parameterizedthreadstart[^] for more info
 
Share this answer
 
I'm a little new, as you can read by my code.(ok a lot new)
I buy the thread start thing, and the "ParameterizedThreadStart" but how do I that, what I'm trying is not working.
Thanks
 
Share this answer
 
I wrote it differently so


Never mind figured it out
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900