コード例 #1
0
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the 
                String[] ActorConfigFileContent = File.ReadAllLines(Configfilename);
                Int32 LineNumber = 0;

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

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

                        ScriptingActorElement NewElement = new ScriptingActorElement();

                        if (TokenizedLine.Length == 5)
                        { 
                            NewElement.SensorToWatchName = TokenizedLine[0];
                            NewElement.SensorValue = Convert.ToDouble(TokenizedLine[1]);
                            NewElement.ActorToSwitchName = TokenizedLine[2];
                            if (TokenizedLine[3].ToUpper() == "ON")
                                NewElement.ActionToRunName = actor_status.On;
                            else
                                if (TokenizedLine[3].ToUpper() == "OFF")
                                    NewElement.ActionToRunName = actor_status.Off;
                                else
                                    if (TokenizedLine[3].ToUpper() == "ONOFF")
                                        NewElement.ActionToRunName = actor_status.OnOff;
                                    else
                                        if (TokenizedLine[3].ToUpper() == "ONWAITOFF")
                                            NewElement.ActionToRunName = actor_status.OnWaitOff;
										else
											if (TokenizedLine[3].ToUpper() == "URL")
												NewElement.ActionToRunName = actor_status.URL;

                            String[] FromToTime = TokenizedLine[4].Split(new char[1] { '-' });
                            NewElement.StartHour = Convert.ToInt32(FromToTime[0]);
                            NewElement.EndHour = Convert.ToInt32(FromToTime[1]);

							ScriptingActorActions.Add(NewElement);
                        }
                        else
                            throw (new Exception("Scripting Actor Configuration File - Error in line "+LineNumber));
                    }
                }
            }
            else
            {
                throw (new Exception("Scripting Actor Configuration File not found! (" + Configfilename+")"));
            }
        }
コード例 #2
0
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the
                String[] ActorConfigFileContent = File.ReadAllLines(Configfilename);
                Int32    LineNumber             = 0;

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

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

                        if (TokenizedLine.Length == 4)
                        {
                            NewElement.SensorToWatchName = TokenizedLine[0];
                            NewElement.SensorValue       = Convert.ToDouble(TokenizedLine[1]);
                            NewElement.ActorToSwitchName = TokenizedLine[2];
                            if (TokenizedLine[3].ToUpper() == "ON")
                            {
                                NewElement.ActionToRunName = actor_status.On;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "OFF")
                            {
                                NewElement.ActionToRunName = actor_status.Off;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "ONOFF")
                            {
                                NewElement.ActionToRunName = actor_status.OnOff;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "ONWAITOFF")
                            {
                                NewElement.ActionToRunName = actor_status.OnWaitOff;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "URL")
                            {
                                NewElement.ActionToRunName = actor_status.URL;
                            }

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