Exemplo n.º 1
0
        private static PointF GetLatLonFromZip(string zipString)
        {
            OSAE osae = new OSAE("Weather");

            if (string.IsNullOrEmpty(zipString))
            {
                throw new ArgumentNullException("zipString");
            }

            PointF latLon = new PointF();

            Weather.gov.weather.www.ndfdXML weatherService = new global::OSAE.Weather.gov.weather.www.ndfdXML();
            try
            {
                string      latLongXml = weatherService.LatLonListZipCode(zipString);
                XmlDocument latLongDoc = new XmlDocument();
                latLongDoc.LoadXml(latLongXml);
                string latLongList = latLongDoc.SelectSingleNode("//latLonList").InnerText;
                // split latLon string and assign them to their respective variables
                string[] latLongArray = latLongList.Split(',');
                float    lat          = float.Parse(latLongArray[0]);
                float    lon          = float.Parse(latLongArray[1]);

                latLon.X = lat;
                latLon.Y = lon;
            }
            catch (Exception ex)
            {
                osae.AddToLog("Error getting Lat/Long: " + ex.Message, false);
                latLon.X = 0;
                latLon.Y = 0;
            }
            return(latLon);
        }
 /// <summary>
 /// The Main Thread: This is where your Service is Run.
 /// </summary>
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         OSAE   osacl   = new OSAE("OSACL");
         string pattern = osacl.MatchPattern(args[0]);
         osacl.AddToLog("Processing command: " + args[0] + ", Named Script: " + pattern, true);
         if (pattern != "")
         {
             osacl.MethodQueueAdd("Script Processor", "NAMED SCRIPT", pattern, "");
         }
     }
     else
     {
         ServiceBase.Run(new OSAEService());
     }
 }
Exemplo n.º 3
0
        // Overide the ProcessRecord method to process
        // the supplied user name and write out a
        // greeting to the user by calling the WriteObject
        // method.
        protected override void ProcessRecord()
        {
            OSAE osae = new OSAE(name);

            OSAEObject obj = osae.GetObjectByName(name);

            if (property != "")
            {
                ObjectProperty objProp = osae.GetObjectPropertyValue(name, property);

                WriteObject(objProp);
            }
            else
            {

                WriteObject(obj);
            }

            //WriteObject("Hello " + name + "!");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Test to see if we can get a successfull connection to the DB
        /// </summary>
        /// <returns></returns>
        public static bool TestConnection()
        {
            bool connectionStatus = true;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(Common.ConnectionString))
                {
                    connection.Open();
                }
            }
            catch
            {
                connectionStatus = false;

                OSAE osae = new OSAE("OSAE.API.Common.TestConnection");
                osae.AddToLog("API - Cannot run query - bad connection: ", true);
            }

            return(connectionStatus);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Test to see if we can get a successfull connection to the DB
        /// </summary>
        /// <returns></returns>
        public static bool TestConnection()
        {
            bool connectionStatus = true;

            try
            {
                using (MySqlConnection connection = new MySqlConnection(Common.ConnectionString))
                {
                    connection.Open();
                }
            }
            catch
            {
                connectionStatus = false;

                OSAE osae = new OSAE("OSAE.API.Common.TestConnection");
                osae.AddToLog("API - Cannot run query - bad connection: ", true);
            }

            return connectionStatus;
        }
        public virtual void ProcessCommand(OSAE.OSAEMethod method)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.DataRow row;
            dt.Columns.Add("method_name", typeof(string));
            dt.Columns.Add("object_name", typeof(string));
            dt.Columns.Add("parameter_1", typeof(string));
            dt.Columns.Add("parameter_2", typeof(string));
            dt.Columns.Add("address", typeof(string));
            dt.Columns.Add("object_owner", typeof(string));

            row = dt.NewRow();
            row["method_name"] = method.MethodName;
            row["object_name"] = method.ObjectName;
            row["parameter_1"] = method.Parameter1;
            row["parameter_2"] = method.Parameter2;
            row["address"] = method.Address;
            row["object_owner"] = method.Owner;
            dt.Rows.Add(row);

            _view.ProcessCommand(dt);
        }
Exemplo n.º 7
0
        private static PointF GetLatLonFromZip(string zipString)
        {
            OSAE osae = new OSAE("Weather");
            if (string.IsNullOrEmpty(zipString))
            {
                throw new ArgumentNullException("zipString");
            }

            PointF latLon = new PointF();
            Weather.gov.weather.www.ndfdXML weatherService = new global::OSAE.Weather.gov.weather.www.ndfdXML();
            try
            {
                string latLongXml = weatherService.LatLonListZipCode(zipString);
                XmlDocument latLongDoc = new XmlDocument();
                latLongDoc.LoadXml(latLongXml);
                string latLongList = latLongDoc.SelectSingleNode("//latLonList").InnerText;
                // split latLon string and assign them to their respective variables
                string[] latLongArray = latLongList.Split(',');
                float lat = float.Parse(latLongArray[0]);
                float lon = float.Parse(latLongArray[1]);

                latLon.X = lat;
                latLon.Y = lon;
            }
            catch(Exception ex)
            {
                osae.AddToLog("Error getting Lat/Long: " + ex.Message, false);
                latLon.X = 0;
                latLon.Y = 0;
            }
            return latLon;
        }
Exemplo n.º 8
0
        //System.Timers.Timer checkPlugins = new System.Timers.Timer();
        /// <summary>
        /// The Main Thread: This is where your Service is Run.
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                OSAE osacl = new OSAE("OSACL");
                Logging commandLineLogging = new Logging("OSACL");

                string pattern = osacl.MatchPattern(args[0]);
                commandLineLogging.AddToLog("Processing command: " + args[0] + ", Named Script: " + pattern, true);
                if (pattern != "")
                    osacl.MethodQueueAdd("Script Processor", "NAMED SCRIPT", pattern, "");
            }
            else
            {
                ServiceBase.Run(new OSAEService());
            }
        }
 public void ProcessCommand(OSAE.OSAEMethod method)
 {
     _contract.ProcessCommand(method);
 }
 public virtual void ProcessCommand(OSAE.OSAEMethod method)
 {
     _view.ProcessCommand(method);
 }
Exemplo n.º 11
0
        public void ProcessCommand(OSAE.OSAEMethod method)
        {
            try
            {
                var properties = osae.GetObjectByAddress(method.Address).Properties;
                int room = 0; int device = 0; int mood = 0;
                osae.AddToLog("LightwaveRF Command: " + method.MethodName, true);
                foreach (var prop in properties)
                {
                    switch (prop.Name.ToLowerInvariant())
                    {
                        case "room":
                            room = int.Parse(prop.Value);
                            osae.AddToLog("LightwaveRF Room: " + room, true);
                            break;
                        case "device":
                            device = int.Parse(prop.Value);
                            osae.AddToLog("LightwaveRF Device: " + device, true);
                            break;
                        case "mood":
                            mood = int.Parse(prop.Value);
                            osae.AddToLog("LightwaveRF Mood: " + mood, true);
                            break;
                    }
                }

                switch (method.MethodName.ToLowerInvariant())
                {
                    case "on":
                        LightwaveRF.API.DeviceOnOff(room, device, State.On);
                        break;
                    case "off":
                        LightwaveRF.API.DeviceOnOff(room, device, State.Off);
                        break;
                    case "dim-10%":
                        LightwaveRF.API.Dim(room, device, 10);
                        break;
                    case "dim-20%":
                        LightwaveRF.API.Dim(room, device, 20);
                        break;
                    case "dim-30%":
                        LightwaveRF.API.Dim(room, device, 30);
                        break;
                    case "dim-40%":
                        LightwaveRF.API.Dim(room, device, 40);
                        break;
                    case "dim-50%":
                        LightwaveRF.API.Dim(room, device, 50);
                        break;
                    case "dim-60%":
                        LightwaveRF.API.Dim(room, device, 60);
                        break;
                    case "dim-70%":
                        LightwaveRF.API.Dim(room, device, 70);
                        break;
                    case "dim-80%":
                        LightwaveRF.API.Dim(room, device, 80);
                        break;
                    case "dim-90%":
                        LightwaveRF.API.Dim(room, device, 90);
                        break;
                    case "heat-on":
                        LightwaveRF.API.HeatOnOff(room, State.On);
                        break;
                    case "heat-off":
                        LightwaveRF.API.HeatOnOff(room, 0);
                        break;
                    case "all-off":
                        LightwaveRF.API.AllOff(room);
                        break;
                    case "mood":
                        LightwaveRF.API.Mood(room, mood);
                        break;
                    case "raw":
                        LightwaveRF.API.sendRaw(method.Parameter1);
                        break;
                    default:
                        osae.AddToLog("unknown method:" + method.MethodName, false);
                        break;

                }
            }
            catch( Exception ex)
                {
                    osae.AddToLog(ex.Message + ex.StackTrace, true);
                }
        }
Exemplo n.º 12
0
 public void ExecuteCommand(OSAE.OSAEMethod method)
 {
     try
     {
         _plugin.ProcessCommand(method);
     }
     catch (Exception ex)
     {
         osae.AddToLog(PluginName + " - Process Command Error: " + ex.Message, true);
     }
 }
Exemplo n.º 13
0
        // Overide the ProcessRecord method to process
        // the supplied user name and write out a
        // greeting to the user by calling the WriteObject
        // method.
        protected override void ProcessRecord()
        {
            OSAE osae = new OSAE(name);

            OSAEObject obj = osae.GetObjectByName(name);

            WriteObject("Name: " + obj.Name);
            WriteObject("State: " + obj.State);
            WriteObject("Description: " + obj.Description);
            WriteObject("Container: " + obj.Container);
            WriteObject("Address: " + obj.Address);
            WriteObject("Enabled: " + obj.Enabled);
            WriteObject("Base Type: " + obj.BaseType);
            WriteObject("Type: " + obj.Type);

            foreach (string method in obj.Methods)
            {
                WriteObject("Method: " + method);
            }

            foreach (ObjectProperty prop in obj.Properties)
            {
                WriteObject("Property (" + prop.DataType + "): " + prop.Name + " Value = " + prop.Value);
            }

            WriteObject("Updated: " + obj.LastUpd);

            //WriteObject("Hello " + name + "!");
        }
Exemplo n.º 14
0
        // Overide the ProcessRecord method to process
        // the supplied user name and write out a
        // greeting to the user by calling the WriteObject
        // method.
        protected override void ProcessRecord()
        {
            OSAE osae = new OSAE(name);

            OSAEObject obj = osae.GetObjectByName(name);

            osae.ObjectPropertySet(name, property, val);

            WriteObject(true);

            //WriteObject("Hello " + name + "!");
        }
Exemplo n.º 15
0
        // Overide the ProcessRecord method to process
        // the supplied user name and write out a
        // greeting to the user by calling the WriteObject
        // method.
        protected override void ProcessRecord()
        {
            OSAE osae = new OSAE(name);

            osae.MethodQueueAdd(name, Method, Value, "");

            WriteObject(true);

            //WriteObject("Hello " + name + "!");
        }