Пример #1
0
        private void PowerOn(ScriptingTimerElement ScriptingTimer)
        {
            ScriptingTimer.LastTimeSwitchedOn = DateTime.Now;
            ScriptingTimer.LastTimeSwitchedOff = DateTime.MinValue;

            // TODO: Power-On Code
            ConsoleOutputLogger.WriteLine("Power On "+ScriptingTimer.SwitchName+" by Timer " + ScriptingTimer.TimerName);
        }
Пример #2
0
        private void PowerOn(ScriptingTimerElement ScriptingTimer)
        {
            ScriptingTimer.LastTimeSwitchedOn  = DateTime.Now;
            ScriptingTimer.LastTimeSwitchedOff = DateTime.MinValue;

            // TODO: Power-On Code
            ConsoleOutputLogger.WriteLine("Power On " + ScriptingTimer.SwitchName + " by Timer " + ScriptingTimer.TimerName);
        }
Пример #3
0
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the 
                String[] TimerConfigFileContent = File.ReadAllLines(Configfilename);
                Int32 LineNumber = 0;

                foreach (String LineElement in TimerConfigFileContent)
                {
                    String[] TokenizedLine = LineElement.Split(new char[1] { ' ' });
                    LineNumber++;

                    if (!LineElement.StartsWith("#"))
                    {

                        ScriptingTimerElement NewElement = new ScriptingTimerElement();

                        if (TokenizedLine.Length == 9)
                        {
                            NewElement.TimerName = TokenizedLine[0];
                            
                            if (!DateTime.TryParse(TokenizedLine[1].Replace('_', ' '), out NewElement.Start))
                                throw (new Exception("Scripting Timers Configuration File - Error in line " + LineNumber + " - Could not parse Start DateTime"));
                            if (!DateTime.TryParse(TokenizedLine[2].Replace('_', ' '), out NewElement.End))
                                throw (new Exception("Scripting Timers Configuration File - Error in line " + LineNumber + " - Could not parse End DateTime"));

                            NewElement.Duration_Start = Convert.ToInt32(TokenizedLine[3]);
                            NewElement.Duration_End = Convert.ToInt32(TokenizedLine[4]);

                            if (TokenizedLine[5].ToUpper() == "ONOFF")
                                NewElement.OperationMode = scripting_timer_operation_modes.OnOff;

                            NewElement.SwitchName = TokenizedLine[6];

                            if (TokenizedLine[7].ToUpper() == "YES")
                                NewElement.Jitter = true;
                            else
                                NewElement.Jitter = false;

                            NewElement.MinimumOnTime = Convert.ToInt32(TokenizedLine[8]);

                            ScriptingTimerActions.Add(NewElement);
                        }
                        else
                            throw (new Exception("Scripting Timer Configuration File - Error in line " + LineNumber));
                    }
                }
            }
            else
            {
                throw (new Exception("Scripting Timer Configuration File not found!"));
            }
        }
Пример #4
0
 private Boolean TimerOverdue(ScriptingTimerElement ScriptingTimer)
 {
     return false;
 }
Пример #5
0
 private Boolean TimerOverdue(ScriptingTimerElement ScriptingTimer)
 {
     return(false);
 }
Пример #6
0
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the
                String[] TimerConfigFileContent = File.ReadAllLines(Configfilename);
                Int32    LineNumber             = 0;

                foreach (String LineElement in TimerConfigFileContent)
                {
                    String[] TokenizedLine = LineElement.Split(new char[1] {
                        ' '
                    });
                    LineNumber++;

                    if (!LineElement.StartsWith("#"))
                    {
                        ScriptingTimerElement NewElement = new ScriptingTimerElement();

                        if (TokenizedLine.Length == 9)
                        {
                            NewElement.TimerName = TokenizedLine[0];

                            if (!DateTime.TryParse(TokenizedLine[1].Replace('_', ' '), out NewElement.Start))
                            {
                                throw (new Exception("Scripting Timers Configuration File - Error in line " + LineNumber + " - Could not parse Start DateTime"));
                            }
                            if (!DateTime.TryParse(TokenizedLine[2].Replace('_', ' '), out NewElement.End))
                            {
                                throw (new Exception("Scripting Timers Configuration File - Error in line " + LineNumber + " - Could not parse End DateTime"));
                            }

                            NewElement.Duration_Start = Convert.ToInt32(TokenizedLine[3]);
                            NewElement.Duration_End   = Convert.ToInt32(TokenizedLine[4]);

                            if (TokenizedLine[5].ToUpper() == "ONOFF")
                            {
                                NewElement.OperationMode = scripting_timer_operation_modes.OnOff;
                            }

                            NewElement.SwitchName = TokenizedLine[6];

                            if (TokenizedLine[7].ToUpper() == "YES")
                            {
                                NewElement.Jitter = true;
                            }
                            else
                            {
                                NewElement.Jitter = false;
                            }

                            NewElement.MinimumOnTime = Convert.ToInt32(TokenizedLine[8]);

                            ScriptingTimerActions.Add(NewElement);
                        }
                        else
                        {
                            throw (new Exception("Scripting Timer Configuration File - Error in line " + LineNumber));
                        }
                    }
                }
            }
            else
            {
                throw (new Exception("Scripting Timer Configuration File not found!"));
            }
        }