protected void Page_Load(object sender, EventArgs e)
 {
     pressObjectName = screenObject.Property("Press Object Name").Value;
     releaseObjectName = screenObject.Property("Press Object Name").Value;
     OSAEObject pObj = OSAEObjectManager.GetObjectByName(pressObjectName);
     OSAEObject rObj = OSAEObjectManager.GetObjectByName(releaseObjectName);
     string pressObjTrust = pObj.MinTrustLevel.ToString();
     string releaseObjTrust = rObj.MinTrustLevel.ToString();
     pressMethodName = screenObject.Property("Press Method Name").Value;
     releaseMethodName = screenObject.Property("Release Method Name").Value;
     pMp1 = screenObject.Property("Press Method Param 1").Value;
     pMp2 = screenObject.Property("Press Method Param 2").Value;
     rMp1 = screenObject.Property("Release Method Param 1").Value;
     rMp2 = screenObject.Property("Release Method Param 2").Value;
     string normalImgName = screenObject.Property("Normal Image").Value;
     string pressImgName = screenObject.Property("Pressed Image").Value;
     OSAEImage img = imgMgr.GetImage(normalImgName);
     OSAEImage img2 = imgMgr.GetImage(pressImgName);
     string normalImgURL = "ImgHandler.aspx?ImageID=" + img.ID;
     string pressImgURL = "ImgHandler.aspx?ImageID=" + img2.ID;
     imgClickImage.ImageUrl = "~/imgHandler.aspx?ImageID=" + img.ID;
     imgClickImage.Attributes.Add("Style", "position:absolute;top:" + (Int32.Parse(screenObject.Property("Y").Value) + 50).ToString() + "px;left:" + (Int32.Parse(screenObject.Property("X").Value) + 10).ToString() + "px;z-index:" + (Int32.Parse(screenObject.Property("ZOrder").Value) + 10).ToString() + ";");
     imgClickImage.ToolTip = pressObjectName + " - " + pressMethodName;
     imgClickImage.Attributes.Add("onmousedown", "methFunc('" + pressObjectName + "','" + pressMethodName + "','" + pMp1 + "','" + pMp2 + "','" + pressObjTrust + "','" + pressImgURL + "', this.id);");
     imgClickImage.Attributes.Add("onmouseup", "methFunc('" + releaseObjectName + "','" + releaseMethodName + "','" + rMp1 + "','" + rMp2 + "','" + releaseObjTrust + "','" + normalImgURL + "', this.id);");
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"] == null)
        {
            Response.Redirect("~/Default.aspx");
        }
        int objSet = OSAEAdminManager.GetAdminSettingsByName("Screen Trust");
        int tLevel = Convert.ToInt32(Session["TrustLevel"].ToString());

        if (tLevel < objSet)
        {
            Response.Redirect("~/permissionError.aspx");
        }

        getRestPort();
        hdnUserTrust.Value = Session["TrustLevel"].ToString();
        debuglabel.Text    = Session["TrustLevel"].ToString();
        gScreen            = Request.QueryString["id"];
        try
        {
            OSAEObject screen = OSAEObjectManager.GetObjectByName(gScreen);
            //List<OSAEScreenControl> controls = OSAEScreenControlManager.GetScreenControls(gScreen);
            OSAEObjectCollection screenObjects = OSAEObjectManager.GetObjectsByContainer(gScreen);
            string    sImg = OSAEObjectPropertyManager.GetObjectPropertyValue(gScreen, "Background Image").Value.ToString();
            OSAEImage img  = imgMgr.GetImage(sImg);
            imgBackground.ImageUrl = "~/ImageHandler.ashx?id=" + img.ID;
            foreach (OSAEObject obj in screenObjects)
            {
                LoadControl(obj);
            }
        }
        catch
        { return; }
    }
        public VideoStreamViewer(string url, OSAEObject obj, string appName)
        {
            InitializeComponent();
            Log = new General.OSAELog(appName);
            screenObject = obj;
            _mjpeg = new MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error += _mjpeg_Error;
            imgWidth = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Width").Value);
            imgHeight = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Height").Value);
            ControlWidth = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Width").Value);
            imgRatio = ControlWidth / imgWidth;
            ControlHeight = Convert.ToDouble(imgHeight * imgRatio);
            streamURI = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
              //  if (imgWidth > 0) { imgWidth = imgWidth); }
               // if (imgHeight > 0) { imgHeight = Convert.ToDouble(imgHeight); }
            this.Width = ControlWidth;
            this.Height = ControlHeight;

            image.Width = ControlWidth;
            image.Height = ControlHeight;
            if (streamURI == null)
            {
                Log.Error("Stream Path Not Found: " + streamURI);
                message.Content = "Can Not Open: " + streamURI;
            }
            else
            {
                streamURI = renameingSys(streamURI);
                Log.Info("Streaming: " + streamURI);
                _mjpeg.ParseStream(new Uri(streamURI));
            }
        }
        public void createdevice(OSAEObject obj)
        {
            MCDevice d = new MCDevice(obj.Name, pName);
            foreach (OSAEObjectProperty prop in obj.Properties)
            {
                switch (prop.Name)
                {
                    case "Type":
                        d.Type = prop.Value;
                        break;
                    case "IP":
                        d.IP = prop.Value;
                        break;
                    case "Network Port":
                        try
                        {
                            d.CommandPort = Int32.Parse(prop.Value);
                        }
                        catch
                        {
                            d.CommandPort = 0;
                        }
                        break;
                }
            }

            mcdevices.Add(d);
            Log.Info("Added MCDevice to list: " + d.Name);

            d.EstablishInitialConnections();
        }
Ejemplo n.º 5
0
        public NavigationImage(string Name, OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            screenName   = Name;

            Image.Tag = screenName;

            string    imgName = screenObject.Property("Image").Value;
            OSAEImage img     = imgMgr.GetImage(imgName);

            if (img != null)
            {
                var imageStream = new MemoryStream(img.Data);
                var bitmapImage = new BitmapImage();

                bitmapImage.BeginInit();
                bitmapImage.StreamSource = imageStream;
                bitmapImage.EndInit();
                Image.Source     = bitmapImage;
                Image.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                Image.Source     = null;
                Image.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 6
0
        public void createdevice(OSAEObject obj)
        {
            MCDevice d = new MCDevice(obj.Name, pName);

            foreach (OSAEObjectProperty prop in obj.Properties)
            {
                switch (prop.Name)
                {
                case "Type":
                    d.Type = prop.Value;
                    break;

                case "IP":
                    d.IP = prop.Value;
                    break;

                case "Network Port":
                    try
                    {
                        d.CommandPort = Int32.Parse(prop.Value);
                    }
                    catch
                    {
                        d.CommandPort = 0;
                    }
                    break;
                }
            }

            mcdevices.Add(d);
            log("Added MCDevice to list: " + d.Name, false);

            d.EstablishInitialConnections();
        }
Ejemplo n.º 7
0
    private void loadDetails()
    {
        OSAEObject obj = OSAEObjectManager.GetObjectByName(gvObjects.DataKeys[Int32.Parse(hdnSelectedRow.Text)]["object_name"].ToString());

        txtName.Text               = obj.Name;
        txtDescr.Text              = obj.Description;
        txtAddress.Text            = obj.Address;
        ddlContainer.SelectedValue = obj.Container;
        if (obj.State.Value != "")
        {
            ddlState.SelectedValue = obj.State.Value;
        }
        ddlType.SelectedValue = obj.Type;
        if (obj.Enabled == 1)
        {
            chkEnabled.Checked = true;
        }
        else
        {
            chkEnabled.Checked = false;
        }

        OSAEObjectType objtype = OSAEObjectTypeManager.ObjectTypeLoad(obj.Type);

        txtOwned.Text = objtype.OwnedBy;
    }
        void OnChecked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dgLocalPlugins.SelectedItem != null)
                {
                    PluginDescription pd = (PluginDescription)dgLocalPlugins.SelectedItem;

                    this.Log.Info("checked: " + pd.Name);

                    NetworkComms.SendObject("Plugin", "127.0.0.1", 10000, pd.Name + "|True");

                    this.Log.Info("Sending message: " + "ENABLEPLUGIN|" + pd.Name + "|True");
                    if (myService.Status == ServiceControllerStatus.Running)
                    {
                        foreach (PluginDescription plugin in pluginList)
                        {
                            if (plugin.Name == pd.Name && plugin.Name != null)
                            {
                                plugin.Status = "Starting...";
                            }
                        }
                    }

                    OSAEObject obj = OSAEObjectManager.GetObjectByName(pd.Name);
                    OSAEObjectManager.ObjectUpdate(obj.Name, obj.Name, obj.Description, obj.Type, obj.Address, obj.Container, 1);
                }
            }
            catch (Exception ex)
            {
                this.Log.Error("Error enabling plugin ", ex);
            }
        }
        public NavigationImage(string Name, OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            screenName = Name;

            Image.Tag = screenName;

            string imgName = screenObject.Property("Image").Value;
            OSAEImage img = imgMgr.GetImage(imgName);

            if (img.Data != null)
            {
                var imageStream = new MemoryStream(img.Data);
                var bitmapImage = new BitmapImage();

                bitmapImage.BeginInit();
                bitmapImage.StreamSource = imageStream;
                bitmapImage.EndInit();
                Image.Source = bitmapImage;
                Image.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                Image.Source = null;
                Image.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 10
0
        private bool validateForm(string mthd)
        {
            bool validate = true;

            // Does this object already exist
            if (mthd == "Add" || sOriginalName != txtScreenName.Text)
            {
                try
                {
                    OSAEObject oExist = OSAEObjectManager.GetObjectByName(txtScreenName.Text);
                    if (oExist != null)
                    {
                        MessageBox.Show("Control name already exist. Please Change!");
                        validate = false;
                    }
                }
                catch { }
            }
            if (string.IsNullOrEmpty(txtScreenName.Text))
            {
                MessageBox.Show("You must enter a Name for this Control!");
                validate = false;
            }
            if (img == null)
            {
                MessageBox.Show("Please specify an image for the screen");
                validate = false;
            }

            return(validate);
        }
Ejemplo n.º 11
0
        public bool CheckObjByName(string Objname)
        {
            bool Objexist = false;

            try
            {
                OSAEObject checkObj = OSAEObjectManager.GetObjectByName(Objname);
                if (checkObj.Name == Objname)
                {
                    if (debug)
                    {
                        this.Log.Debug("The object " + checkObj.Name + " Was found.");
                    }
                    Objexist = true;
                }
            }
            catch
            {
                Objexist = false;
                if (debug)
                {
                    this.Log.Debug("The object " + Objname + " Was not found.");
                }
            }
            return(Objexist);
        }
Ejemplo n.º 12
0
        public void sendtext(OSAEMethod method)
        {
            bool reg = checkStatus(method);

            if (reg == true)
            {
                try
                {
                    objName                  = method.ObjectName;
                    sonyobj                  = OSAEObjectManager.GetObjectByName(objName);
                    mySonyDevice.Name        = sonyobj.Name;
                    mySonyDevice.DocumentUrl = sonyobj.Property("DocumentURL").Value;
                    mySonyDevice.ServerName  = "OSAE.Sony";
                    mySonyDevice.BuildFromDocument(new Uri(mySonyDevice.DocumentUrl));
                    mySonyDevice.SendText(method.Parameter1);
                }
                catch (Exception ex)
                {
                    this.Log.Info("An error occurred!!!: " + ex.Message);
                    if (debug)
                    {
                        this.Log.Debug("The Send Text method was unsuccessful.");
                    }
                }
            }
        }
Ejemplo n.º 13
0
        protected override void ProcessRecord()
        {
            logging.AddToLog("Get-OSA - ProcessRecord - Started", false);
            OSAEObject obj = OSAEObjectManager.GetObjectByName(Name);

            WriteObject(obj);
        }
Ejemplo n.º 14
0
        public void enablePlugin(Plugin plugin)
        {
            OSAEObject obj = osae.GetObjectByName(plugin.PluginName);

            osae.ObjectUpdate(plugin.PluginName, plugin.PluginName, obj.Description, obj.Type, obj.Address, obj.Container, 1);
            try
            {
                if (plugin.ActivatePlugin())
                {
                    plugin.addin.RunInterface(plugin.PluginName);
                    osae.ObjectStateSet(plugin.PluginName, "ON");
                    sendMessageToClients("plugin", plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Running | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + osae.ComputerName);
                    osae.AddToLog("Plugin enabled: " + plugin.PluginName, true);
                    osae.AddToLog("Process ID: " + plugin.process.ProcessId.ToString(), true);
                }
            }
            catch (Exception ex)
            {
                osae.AddToLog("Error activating plugin (" + plugin.PluginName + "): " + ex.Message + " - " + ex.InnerException, true);
            }
            catch
            {
                osae.AddToLog("Error activating plugin", true);
            }
        }
Ejemplo n.º 15
0
        //private string serviceName;
        public void startPlugin(string serviceName, Plugin plugin)
        {
            Log = new General.OSAELog(serviceName);
            Log.Info(plugin.PluginName + ":  Starting Plugin...");

            OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);

            //Enabe and start seemed to be mixed, changed to start, enabe is handled at the Webui for now, maybe a method in the future
            //OSAEObjectManager.ObjectUpdate(plugin.PluginName, plugin.PluginName, obj.Alias, obj.Description, obj.Type, obj.Address, obj.Container, obj.MinTrustLevel, true);
            try
            {
                if (plugin.ActivatePlugin())
                {
                    // plugin.Enabled = true;
                    plugin.RunInterface(serviceObject);
                    OSAEObjectStateManager.ObjectStateSet(plugin.PluginName, "ON", "SYSTEM");
                    Log.Debug(plugin.PluginName + ":  Plugin started.");
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error activating plugin (" + plugin.PluginName + "): " + ex.Message, ex);
                OSAEObjectStateManager.ObjectStateSet(plugin.PluginName, "OFF", "SYSTEM");
            }
        }
 public VideoStreamViewer(string url, OSAEObject obj)
 {
     InitializeComponent();
     screenObject = obj;
     _mjpeg = new MjpegDecoder();
     _mjpeg.FrameReady += mjpeg_FrameReady;
     _mjpeg.Error += _mjpeg_Error;
     var imgsWidth = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Width").Value;
     var imgsHeight = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Height").Value;
     streamURI = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
     if (imgsWidth != "") { imgWidth = Convert.ToDouble(imgsWidth); }
     if (imgsHeight != "") { imgHeight = Convert.ToDouble(imgsHeight); }
     this.Width = imgWidth;
     this.Height = imgHeight;
     image.Width = imgWidth;
     image.Height = imgHeight;
     if (streamURI == null)
     {
         this.Log.Error("Stream Path Not Found: " + streamURI);
         message.Content = "Can Not Open: " + streamURI;
     }
     else
     {
         streamURI = renameingSys(streamURI);
         this.Log.Info("Streaming: " + streamURI);
         _mjpeg.ParseStream(new Uri(streamURI));
     }
 }
Ejemplo n.º 17
0
        public VideoStreamViewer(string url, OSAEObject obj, string appName)
        {
            InitializeComponent();
            Log                = new General.OSAELog(appName);
            screenObject       = obj;
            _mjpeg             = new MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error      += _mjpeg_Error;
            imgWidth           = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Width").Value);
            imgHeight          = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Height").Value);
            ControlWidth       = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Width").Value);
            imgRatio           = ControlWidth / imgWidth;
            ControlHeight      = Convert.ToDouble(imgHeight * imgRatio);
            streamURI          = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
            //  if (imgWidth > 0) { imgWidth = imgWidth); }
            // if (imgHeight > 0) { imgHeight = Convert.ToDouble(imgHeight); }
            this.Width  = ControlWidth;
            this.Height = ControlHeight;

            image.Width  = ControlWidth;
            image.Height = ControlHeight;
            if (streamURI == null)
            {
                Log.Error("Stream Path Not Found: " + streamURI);
                message.Content = "Can Not Open: " + streamURI;
            }
            else
            {
                streamURI = renameingSys(streamURI);
                Log.Info("Streaming: " + streamURI);
                _mjpeg.ParseStream(new Uri(streamURI));
            }
        }
Ejemplo n.º 18
0
        protected override void ProcessRecord()
        {
            logging.AddToLog("Show-OSA - ProcessRecord - Started", false);
            OSAEObject obj = OSAEObjectManager.GetObjectByName(Name);

            WriteObject("Name: " + obj.Name);
            WriteObject("State: " + obj.State.Value);
            WriteObject("Description: " + obj.Description);
            WriteObject("Container: " + obj.Container);
            WriteObject("Address: " + obj.Address);

            if (obj.Enabled == 0)
            {
                WriteObject("Enabled: FALSE");
            }
            else
            {
                WriteObject("Enabled: TRUE");
            }

            WriteObject("Base Type: " + obj.BaseType);
            WriteObject("Type: " + obj.Type);

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

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

            WriteObject("Updated: " + obj.LastUpd);
        }
        public MethodImage(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject             = sObj;
            ObjectName               = screenObject.Property("Object Name").Value;;
            MethodName               = screenObject.Property("Method Name").Value;;
            Param1                   = screenObject.Property("Param 1").Value;;
            Param2                   = screenObject.Property("Param 2").Value;;
            Image.Tag                = ObjectName + " - " + MethodName;
            Image.ToolTip            = Image.Tag;
            Image.MouseLeftButtonUp += new MouseButtonEventHandler(Method_Image_MouseLeftButtonUp);

            string    imgName = screenObject.Property("Image").Value;
            OSAEImage img     = imgMgr.GetImage(imgName);

            if (img.Data != null)
            {
                var imageStream = new MemoryStream(img.Data);
                var bitmapImage = new BitmapImage();

                bitmapImage.BeginInit();
                bitmapImage.StreamSource = imageStream;
                bitmapImage.EndInit();
                Image.Source     = bitmapImage;
                Image.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                Image.Source     = null;
                Image.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 20
0
        UInt32 pollInterval = 250; // 4x a second
        #endregion

        private void AddIO(string address, Direction dir, string serial, byte id)
        {
            if (OSAEObjectManager.GetObjectByAddress(address) == null)
            {
                if (dir == Direction.Input)
                {
                    OSAEObjectManager.ObjectAdd("J-Works-I" + address, "", "J -Works input", "JWORKS INPUT", address, "", 30, true);
                }
                else
                {
                    OSAEObjectManager.ObjectAdd("J-Works-0" + address, "", "J-Works output", "JWORKS OUTPUT", address, "", 30, true);
                }

                OSAEObjectPropertyManager.ObjectPropertySet(address, "Serial", serial, pName);
                OSAEObjectPropertyManager.ObjectPropertySet(address, "Id", Convert.ToString(id), pName);
                OSAEObjectPropertyManager.ObjectPropertySet(address, "Invert", "FALSE", pName);
            }

            OSAEObject obj = OSAEObjectManager.GetObjectByAddress(address);

            bool invert = (OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Invert").Value == "TRUE");

            // initial state is 0; interpret that in light of Invert setting
            OSAEObjectStateManager.ObjectStateSet(obj.Name, invert ? "ON" : "OFF", pName);
        }
        public MethodImage(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            ObjectName = screenObject.Property("Object Name").Value; ;
            MethodName = screenObject.Property("Method Name").Value; ;
            Param1 = screenObject.Property("Param 1").Value; ;
            Param2 = screenObject.Property("Param 2").Value; ;

            Image.Tag = ObjectName + " - " + MethodName;
            Image.MouseLeftButtonUp += new MouseButtonEventHandler(Method_Image_MouseLeftButtonUp);

            string imgName = screenObject.Property("Image").Value;
            OSAEImage img = imgMgr.GetImage(imgName);

            if (img.Data != null)
            {
                var imageStream = new MemoryStream(img.Data);
                var bitmapImage = new BitmapImage();

                bitmapImage.BeginInit();
                bitmapImage.StreamSource = imageStream;
                bitmapImage.EndInit();
                Image.Source = bitmapImage;
                Image.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                Image.Source = null;
                Image.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 22
0
        void OnUnchecked(object sender, RoutedEventArgs e)
        {
            try
            {
                PluginDescription pd = (PluginDescription)dgLocalPlugins.SelectedItem;

                this.Log.Info("Updating Object: " + pd.Name + ", Setting Enabled=False");
                OSAEObject obj = OSAEObjectManager.GetObjectByName(pd.Name);
                OSAEObjectManager.ObjectUpdate(obj.Name, obj.Name, obj.Alias, obj.Description, obj.Type, obj.Address, obj.Container, 0);

                //   NetworkComms.SendObject("Plugin", "127.0.0.1", 10051, pd.Name + "|False");
                //   this.Log.Info("Sending message: " + "ENABLEPLUGIN|" + pd.Name + "|False");


                //    if (myService.Status == ServiceControllerStatus.Running)
                //    {
                //       foreach (PluginDescription plugin in pluginList)
                //       {
                //           if (plugin.Name == pd.Name && plugin.Name != null)
                //           {
                //              plugin.Status = "Stopping...";
                //           }
                //       }
                //   }
            }
            catch (Exception ex)
            {
                this.Log.Error("Error disabling plugin", ex);
            }
        }
Ejemplo n.º 23
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try {
                string object_name = method.ObjectName;
                string method_name = method.MethodName;
                string parameter_1 = method.Parameter1;
                string parameter_2 = method.Parameter2;

                Log.Debug("Found Command: " + method_name + " | param1: " + parameter_1 + " | param2: " + parameter_2);

                if (object_name == pName)
                {
                    switch (method_name)
                    {
                    case "NOTIFYALL":
                        Log.Debug("NOTIFYALL event triggered");
                        Log.Debug("NOTIFYALL devices to loop:" + mdevices.Count);

                        foreach (AndroidDevice d in mdevices)
                        {
                            Log.Debug("NOTIFYALL loop for device:" + d.Name);
                            d.ProcessCommand("NOTIFY", parameter_1, parameter_2);
                        }

                        break;

                    case "EXECUTEALL":
                        Log.Debug("EXECUTEALL event triggered");
                        Log.Debug("EXECUTEALL devices to loop:" + mdevices.Count);

                        foreach (AndroidDevice d in mdevices)
                        {
                            Log.Debug("EXECUTEALL loop for device:" + d.Name);
                            d.ProcessCommand("EXECUTE", parameter_1, parameter_2);
                        }
                        break;
                    }
                }
                else
                {
                    AndroidDevice d = getAndroidDevice(object_name);

                    if (d == null)
                    {
                        OSAEObject obj = OSAEObjectManager.GetObjectByName(object_name);
                        createdevice(obj);
                        d = getAndroidDevice(object_name);
                    }

                    if (d != null)
                    {
                        d.ProcessCommand(method_name, parameter_1, parameter_2);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error processing command!", ex);
            }
        }
Ejemplo n.º 24
0
        public VideoStreamViewer(string url, OSAEObject obj)
        {
            InitializeComponent();
            screenObject       = obj;
            _mjpeg             = new MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error      += _mjpeg_Error;
            var imgsWidth  = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Width").Value;
            var imgsHeight = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Height").Value;

            streamURI = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
            if (imgsWidth != "")
            {
                imgWidth = Convert.ToDouble(imgsWidth);
            }
            if (imgsHeight != "")
            {
                imgHeight = Convert.ToDouble(imgsHeight);
            }
            this.Width   = imgWidth;
            this.Height  = imgHeight;
            image.Width  = imgWidth;
            image.Height = imgHeight;
            if (streamURI == null)
            {
                this.Log.Error("Stream Path Not Found: " + streamURI);
                message.Content = "Can Not Open: " + streamURI;
            }
            else
            {
                streamURI = renameingSys(streamURI);
                this.Log.Info("Streaming: " + streamURI);
                _mjpeg.ParseStream(new Uri(streamURI));
            }
        }
    protected void imgSubmit_Click(object sender, EventArgs e)
    {
        OSAEObject obj = OSAEObjectManager.GetObjectByName(txtUserName.Text);

        if (obj != null)
        {
            string pass = obj.Property("Password").Value;
            if (pass == txtPassword.Text)
            {
                if (pass != "")
                {
                    // Success, create non-persistent authentication cookie.
                    FormsAuthentication.SetAuthCookie(txtUserName.Text.Trim(), false);
                    Int32 cto = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue("Web Server", "Timeout").Value);
                    FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket(txtUserName.Text.Trim(), true, cto);
                    HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1));
                    Response.Cookies.Add(cookie1);
                    Session["UserName"]      = OSAEObjectManager.GetObjectByName(this.txtUserName.Text.Trim()).Name;
                    Session["TrustLevel"]    = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Trust Level").Value;
                    Session["SecurityLevel"] = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Security Level").Value;
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(txtUserName.Text.Trim(), false);
                    Int32 cto = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue("Web Server", "Timeout").Value);
                    FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket(txtUserName.Text.Trim(), true, cto);
                    HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1));
                    Response.Cookies.Add(cookie1);
                    Session["UserName"]      = OSAEObjectManager.GetObjectByName(this.txtUserName.Text.Trim()).Name;
                    Session["TrustLevel"]    = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Trust Level").Value;
                    Session["SecurityLevel"] = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Security Level").Value;
                }
                // 4. Do the redirect.
                string    returnUrl1;
                OSAEAdmin adSet  = OSAEAdminManager.GetAdminSettings();
                int       tLevel = Convert.ToInt32(Session["TrustLevel"].ToString());
                if (Session["SecurityLevel"].ToString() != "Admin" & tLevel < adSet.ObjectsTrust)
                {
                    returnUrl1 = "screens.aspx?id=" + adSet.defaultScreen;
                }
                else
                {
                    if (Request.QueryString["ReturnUrl"] == null)
                    {
                        returnUrl1 = "objects.aspx";                                            // the login is successful
                    }
                    else
                    {
                        returnUrl1 = Request.QueryString["ReturnUrl"];   //login not unsuccessful
                    }
                }
                Response.Redirect(returnUrl1);
            }
            else
            {
                lblError.Visible = true;
            }
        }
        lblError.Visible = true;
    }
Ejemplo n.º 26
0
        void OnUnchecked(object sender, RoutedEventArgs e)
        {
            try
            {
                PluginDescription pd = (PluginDescription)dgLocalPlugins.SelectedItem;
                logging.AddToLog("unchecked: " + pd.Name, true);

                Thread thread = new Thread(() => messageHost(OSAEWCFMessageType.PLUGIN, "ENABLEPLUGIN|" + pd.Name + "|False"));
                thread.Start();
                logging.AddToLog("Sending message: " + "ENABLEPLUGIN|" + pd.Name + "|False", true);

                if (myService.Status == ServiceControllerStatus.Running)
                {
                    foreach (PluginDescription plugin in pluginList)
                    {
                        if (plugin.Name == pd.Name && plugin.Name != null)
                        {
                            plugin.Status = "Stopping...";
                        }
                    }
                }

                OSAEObject obj = OSAEObjectManager.GetObjectByName(pd.Name);
                OSAEObjectManager.ObjectUpdate(obj.Name, obj.Name, obj.Description, obj.Type, obj.Address, obj.Container, 0);
            }
            catch (Exception ex)
            {
                logging.AddToLog("Error disabling plugin: " + ex.Message, true);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Public Constructor for WindowsService.
        /// - Put all of your Initialization code here.
        /// </summary>
        public OSAEService()
        {
            serviceObject = CheckServiceObject();
            if (serviceObject == null)
            {
                Log = new General.OSAELog("Faulted Service");
                Log.Fatal("Failed to retrieve Service's Object!");
            }
            //else
            //   OSAE.OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject);

            Log = new General.OSAELog(serviceObject);
            Log.Info("Service Starting");

            Common.CheckComputerObject(serviceObject);
            OSAEObject obj = OSAEObjectManager.GetObjectByName(serviceObject);

            OSAEObjectManager.ObjectUpdate(serviceObject, serviceObject, obj.Address, obj.Description, obj.Type, obj.Address, Common.ComputerName, obj.MinTrustLevel, obj.Enabled);

            InitialiseOSAInEventLog();

            // These Flags set whether or not to handle that specific type of event. Set to true if you need it, false otherwise.

            CanStop     = true;
            CanShutdown = true;
        }
Ejemplo n.º 28
0
        public void updateonline()
        {
            OSAEObjectCollection sonydevices = OSAEObjectManager.GetObjectsByOwner("Sony");

            if (refresh > 0)
            {
                foreach (OSAEObject device in sonydevices)
                {
                    string objName = device.Name;
                    if (objName != "Sony")
                    {
                        if (device.Property("Registered").Value == "TRUE")
                        {
                            if (debug)
                            {
                                this.Log.Debug("Updating Online Status for: " + objName);
                            }
                            sonyobj = OSAEObjectManager.GetObjectByName(objName);
                            if (debug)
                            {
                                this.Log.Debug("Initializing: " + sonyobj.Name);
                            }
                            mySonyDevice.Name        = sonyobj.Name;
                            mySonyDevice.DocumentUrl = sonyobj.Property("DocumentURL").Value;
                            mySonyDevice.ServerName  = "OSAE.Sony";
                            mySonyDevice.BuildFromDocument(new Uri(mySonyDevice.DocumentUrl));
                            OSAEMethod updatereg = new OSAEMethod();
                            updatereg.ObjectName = mySonyDevice.Name;
                            checkStatus(updatereg);
                        }
                    }
                }
            }
        }
Ejemplo n.º 29
0
        protected override void ProcessRecord()
        {
            this.Log.Debug("Get-OSA - ProcessRecord - Started");
            OSAEObject obj = OSAEObjectManager.GetObjectByName(Name);

            WriteObject(obj);
        }
        public NavigationImage(string Name, string path, OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            screenName = Name;
            imgPath = osae.APIpath + path;

            Image.Tag = screenName;
            if (File.Exists(imgPath))
            {
                byte[] byteArray = File.ReadAllBytes(imgPath);
                var imageStream = new MemoryStream(byteArray);
                var bitmapImage = new BitmapImage();

                bitmapImage.BeginInit();
                bitmapImage.StreamSource = imageStream;
                bitmapImage.EndInit();
                Image.Source = bitmapImage;
                Image.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                Image.Source = null;
                Image.Visibility = System.Windows.Visibility.Hidden;
            }
        }
        public UserSelector(OSAEObject sObject, string appName)
        {
            InitializeComponent();
            userGrid.Height = 25;
            _AppName        = appName;
            screenObject    = sObject;
            cboUsers.Items.Add("Log In/Out");
            cboUsers.SelectedIndex = 1;

            string currentUser = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(_AppName, "Current User").Value;

            cboUsers.Background = new SolidColorBrush(Colors.Yellow);

            OSAEObjectCollection userList = OSAEObjectManager.GetObjectsByType("PERSON");

            foreach (OSAE.OSAEObject obj in userList)
            {
                cboUsers.Items.Add(obj.Name);
                if (obj.Name == currentUser)
                {
                    cboUsers.SelectedIndex = cboUsers.Items.Count - 1;
                    _CurrentUser           = currentUser;
                    _CurrentUserTrust      = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(_CurrentUser, "Trust Level").Value);
                    cboUsers.Background    = new SolidColorBrush(Colors.Green);

                    // Add Remember me option
                    ContextMenu ctmRembMe = new ContextMenu();
                    MenuItem    miRembMe  = new MenuItem();
                    miRembMe.Name        = "rememberMode";
                    miRembMe.IsCheckable = true;
                    miRembMe.Checked    += rememberMode_Checked;
                    miRembMe.Unchecked  += rememberMode_Unchecked;
                    miRembMe.Header      = "LogOut on Close";
                    string remUser = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(_AppName, "LogOut on Close").Value;
                    bool   loUser  = Convert.ToBoolean(remUser);
                    if (loUser == true)
                    {
                        miRembMe.IsChecked = true;
                    }
                    else
                    {
                        miRembMe.IsChecked = false;
                    }
                    ctmRembMe.Items.Add(miRembMe);
                    cboUsers.ContextMenu = ctmRembMe;
                }
            }



            // string imgName = screenObject.Property("Image").Value;
            // OSAEImage img = imgMgr.GetImage(imgName);

            //  if (img != null)
            // DataSet dataSet = OSAESql.RunSQL("SELECT state_name FROM osae_v_object_state where object_name = '" + cboObject.SelectedValue + "' order by state_name");
            //cboState1.ItemsSource = dataSet.Tables[0].DefaultView;

            loadingFlag = false;
        }
 public VideoStreamViewer(string url, OSAEObject obj)
 {
     InitializeComponent();
     screenObject = obj;
     _mjpeg = new MjpegDecoder();
     _mjpeg.FrameReady += mjpeg_FrameReady;
     _mjpeg.ParseStream(new Uri(url));
 }
Ejemplo n.º 33
0
        public OSAEObject GetObject(string name)
        {
            // lookup object
            OSAEObject OSAEobj = OSAEObjectManager.GetObjectByName(name);

            OSAEobj.Properties = getProperties(OSAEobj.Name);
            return(OSAEobj);
        }
        public PropertyLabel(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            ObjectName = screenObject.Property("Object Name").Value;
            PropertyName = screenObject.Property("Property Name").Value;

            string sPropertyValue = osae.GetObjectPropertyValue(ObjectName, PropertyName).Value;
            string sBackColor = screenObject.Property("Back Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string sPrefix = screenObject.Property("Prefix").Value;
            string sSuffix = screenObject.Property("Suffix").Value;
            string iFontSize = screenObject.Property("Font Size").Value;
            string sFontName = screenObject.Property("Font Name").Value;

            if (sPropertyValue != "")
            {
                if (sBackColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                        propLabel.Background = brush;
                    }
                    catch (Exception myerror)
                    {
                    }
                }
                if (sForeColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                        propLabel.Foreground = brush;
                    }
                    catch (Exception myerror)
                    {
                    }
                }
                if (iFontSize != "")
                {
                    try
                    {
                        propLabel.FontSize = Convert.ToDouble(iFontSize);
                    }
                    catch (Exception myerror)
                    {
                    }
                }
                propLabel.Content = sPrefix + sPropertyValue + sSuffix;
            }
            else
            {
                propLabel.Content = "";
            }
        }
Ejemplo n.º 35
0
        public PropertyLabel(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            ObjectName   = screenObject.Property("Object Name").Value;
            PropertyName = screenObject.Property("Property Name").Value;

            string sPropertyValue = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, PropertyName).Value;
            string sBackColor     = screenObject.Property("Back Color").Value;
            string sForeColor     = screenObject.Property("Fore Color").Value;
            string sPrefix        = screenObject.Property("Prefix").Value;
            string sSuffix        = screenObject.Property("Suffix").Value;
            string iFontSize      = screenObject.Property("Font Size").Value;
            string sFontName      = screenObject.Property("Font Name").Value;

            if (sPropertyValue != "")
            {
                if (sBackColor != "")
                {
                    try
                    {
                        BrushConverter  conv  = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                        propLabel.Background = brush;
                    }
                    catch (Exception)
                    {
                    }
                }
                if (sForeColor != "")
                {
                    try
                    {
                        BrushConverter  conv  = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                        propLabel.Foreground = brush;
                    }
                    catch (Exception)
                    {
                    }
                }
                if (iFontSize != "")
                {
                    try
                    {
                        propLabel.FontSize = Convert.ToDouble(iFontSize);
                    }
                    catch (Exception)
                    {
                    }
                }
                propLabel.Content = sPrefix + sPropertyValue + sSuffix;
            }
            else
            {
                propLabel.Content = "";
            }
        }
Ejemplo n.º 36
0
        public override void RunInterface(string pluginName)
        {
            this.Log.Info("Found Plugin Object: " + pluginName);
            this.Log.Info(pluginName + " is starting...");
            OSAEObject plugin = OSAEObjectManager.GetObjectByName(pluginName);
            string     refsh  = plugin.Property("Refresh").Value;

            debug = Convert.ToBoolean(plugin.Property("Debug").Value);

            // Set API Logging
            mySonyLib.Log.Enable = true;

            // If Plugin Debug is TRUE:
            if (debug)
            {
                // then Log ALL Lines!
                mySonyLib.Log.Level = "All";
            }
            else
            {
                // else only Log BASIC Lines!
                mySonyLib.Log.Level = "Basic";
            }
            // Sets Logging to OSA Plugins folder
            mySonyLib.Log.Path = OSAE.Common.ApiPath + @"\Plugins\Sony\";
            mySonyLib.Log.Name = "SonyPlugin_LOG.txt";

            //Start a new file every time service is restarted
            // Old file is renamed with Time/Date Stamp.
            string saveLogDate = DateTime.Now.ToShortDateString();

            saveLogDate = saveLogDate.Replace("/", "_");
            string saveLogTime = DateTime.Now.ToShortTimeString();

            saveLogTime = saveLogTime.Replace(":", "_");
            saveLogTime.Replace(" ", "");
            string saveLog = saveLogDate + "_" + saveLogTime + "_SonyPlugin_OLD.txt";

            mySonyLib.Log.ClearLog(saveLog);

            // Setup Update Timer
            OnlineUpdateTimer = new System.Timers.Timer();
            refresh           = Convert.ToInt16(refsh);
            if (refresh == 0)
            {
                Onlineupdatetime = Onlineupdatetime * 1;
            }
            else
            {
                Onlineupdatetime = Onlineupdatetime * refresh;
            }
            OnlineUpdateTimer.Interval = Onlineupdatetime;
            OnlineUpdateTimer.Start();
            OnlineUpdateTimer.Elapsed += new ElapsedEventHandler(OnlineUpdateTime);
            this.updateOnlineThread    = new Thread(new ThreadStart(updateonline));
            this.updateOnlineThread.Start();
            Thread.Sleep(5000);
        }
        private bool ValidateForm(string mthd)
        {
            bool validate = true;

            // Does this object already exist
            if (mthd == "Add" || sOriginalName != cntrlName.Text)
            {
                try
                {
                    OSAEObject oExist = OSAEObjectManager.GetObjectByName(cntrlName.Text);
                    if (oExist != null)
                    {
                        MessageBox.Show("Control name already exist. Please Change!");
                        validate = false;
                    }
                }
                catch { }
            }
            if (string.IsNullOrEmpty(cntrlName.Text))
            {
                MessageBox.Show("Please specify a name for the control");
                validate = false;
            }
            if (objectsComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please Choose a Object to Associate");
                validate = false;
            }
            if (string.IsNullOrEmpty(cntrlX.Text))
            {
                MessageBox.Show("X Can not be empty");
                validate = false;
            }
            if (string.IsNullOrEmpty(cntrlY.Text))
            {
                MessageBox.Show("Y Can not be empty");
                validate = false;
            }
            if (string.IsNullOrEmpty(cntrlZOrder.Text))
            {
                MessageBox.Show("ZOrder can not be empty");
                validate = false;
            }
            if (hasParams == true)
            {
                foreach (objParams op in oParams)
                {
                    if (string.IsNullOrEmpty(op.Value))
                    {
                        MessageBox.Show("An additioanl Parameter is empty");
                        validate = false;
                    }
                }
            }

            return(validate);
        }
Ejemplo n.º 38
0
        public override void ProcessCommand(OSAEMethod method)
        {
            String object_name = method.ObjectName;
            String method_name = method.MethodName;
            String parameter_1 = method.Parameter1;
            String parameter_2 = method.Parameter2;

            log("Found Command: " + method_name + " | param1: " + parameter_1 + " | param2: " + parameter_2, true);

            if (object_name == pName)
            {
                switch (method_name)
                {
                case "NOTIFYALL":
                    log("NOTIFYALL event triggered", false);

                    log("NOTIFYALL devices to loop:" + mdevices.Count, false);

                    foreach (AndroidDevice d in mdevices)
                    {
                        log("NOTIFYALL loop for device:" + d.Name, false);
                        d.ProcessCommand("NOTIFY", parameter_1, parameter_2);
                    }

                    break;

                case "EXECUTEALL":
                    log("EXECUTEALL event triggered", false);

                    log("EXECUTEALL devices to loop:" + mdevices.Count, false);

                    foreach (AndroidDevice d in mdevices)
                    {
                        log("EXECUTEALL loop for device:" + d.Name, false);
                        d.ProcessCommand("EXECUTE", parameter_1, parameter_2);
                    }

                    break;
                }
            }
            else
            {
                AndroidDevice d = getAndroidDevice(object_name);

                if (d == null)
                {
                    OSAEObject obj = OSAEObjectManager.GetObjectByName(object_name);
                    createdevice(obj);
                    d = getAndroidDevice(object_name);
                }

                if (d != null)
                {
                    d.ProcessCommand(method_name, parameter_1, parameter_2);
                }
            }
        }
        public UserSelector(OSAEObject sObject, string appName)
        {
            InitializeComponent();
            userGrid.Height = 25;
            _AppName = appName;
            screenObject = sObject;
            cboUsers.Items.Add("Log In/Out");
            cboUsers.SelectedIndex = 1;

            string currentUser = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(_AppName, "Current User").Value;

            cboUsers.Background = new SolidColorBrush(Colors.Yellow);

            OSAEObjectCollection userList = OSAEObjectManager.GetObjectsByType("PERSON");
            foreach (OSAE.OSAEObject obj in userList)
            {
                cboUsers.Items.Add (obj.Name);
                if (obj.Name == currentUser)
                {
                    cboUsers.SelectedIndex = cboUsers.Items.Count - 1;
                    _CurrentUser = currentUser;
                    _CurrentUserTrust = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(_CurrentUser, "Trust Level").Value);
                    cboUsers.Background = new SolidColorBrush(Colors.Green);

                    // Add Remember me option
                    ContextMenu ctmRembMe = new ContextMenu();
                    MenuItem miRembMe = new MenuItem();
                    miRembMe.Name = "rememberMode";
                    miRembMe.IsCheckable = true;
                    miRembMe.Checked += rememberMode_Checked;
                    miRembMe.Unchecked += rememberMode_Unchecked;
                    miRembMe.Header = "LogOut on Close";
                    string remUser = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(_AppName, "LogOut on Close").Value;
                    bool loUser = Convert.ToBoolean(remUser);
                    if (loUser == true)
                    {
                        miRembMe.IsChecked = true;
                    }
                    else
                    {
                        miRembMe.IsChecked = false;
                    }
                    ctmRembMe.Items.Add(miRembMe);
                    cboUsers.ContextMenu = ctmRembMe;
                }
            }

            // string imgName = screenObject.Property("Image").Value;
            // OSAEImage img = imgMgr.GetImage(imgName);

            //  if (img != null)
            // DataSet dataSet = OSAESql.RunSQL("SELECT state_name FROM osae_v_object_state where object_name = '" + cboObject.SelectedValue + "' order by state_name");
            //cboState1.ItemsSource = dataSet.Tables[0].DefaultView;

            loadingFlag = false;
        }
 public ScreenObjectList(OSAEObject sObject, string screen,string user)
 {
     InitializeComponent();
     currentUser = user;
     currentScreen = screen;
     screenObject = sObject;
     OSAEObjectCollection _objs = OSAEObjectManager.GetObjectsByContainer(currentScreen);
     foreach (OSAEObject _obj in _objs)
         lbControls.Items.Add(_obj.Name);
 }
        public StaticLabel(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;

            string sValue = screenObject.Property("Value").Value; ;
            string sBackColor = screenObject.Property("Background Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string iFontSize = screenObject.Property("Font Size").Value;
            string sFontName = screenObject.Property("Font Name").Value;

            if (sValue != "")
            {
                if (sBackColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                        staticLabel.Background = brush;
                    }
                    catch (Exception myerror)
                    {
                    }
                }
                if (sForeColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                        staticLabel.Foreground = brush;
                    }
                    catch (Exception myerror)
                    {
                    }
                }
                if (iFontSize != "")
                {
                    try
                    {
                        staticLabel.FontSize = Convert.ToDouble(iFontSize);
                    }
                    catch (Exception myerror)
                    {
                    }
                }
                staticLabel.Content = sValue;
            }
            else
            {
                staticLabel.Content = "";
            }

        }
 public BrowserFrame(OSAEObject sObject)
 {
     InitializeComponent();
     screenObject = sObject;
     try
     {
         Uri uriproperty = new Uri(screenObject.Property("URI").Value);
         wbBrowser.Source = uriproperty;
     }
     catch { }
 }
        public ClickImage(OSAEObject sObj, string appName, string user)
        {
            InitializeComponent();
            screenObject = sObj;
            gAppName = appName;
            currentUser = user;
            PressObjectName = screenObject.Property("Press Object Name").Value;
            PressMethodName = screenObject.Property("Press Method Name").Value;
            PressMethodParam1 = screenObject.Property("Press Method Param 1").Value;
            PressMethodParam2 = screenObject.Property("Press Method Param 2").Value;
            PressScriptName = screenObject.Property("Press Script Name").Value;
            PressScriptParam1 = screenObject.Property("Press Script Param 1").Value;
            PressScriptParam2 = screenObject.Property("Press Script Param 2").Value;

            ReleaseObjectName = screenObject.Property("Release Object Name").Value;
            ReleaseMethodName = screenObject.Property("Release Method Name").Value;
            ReleaseMethodParam1 = screenObject.Property("Release Method Param 1").Value;
            ReleaseMethodParam2 = screenObject.Property("Release Method Param 2").Value;
            ReleaseScriptName = screenObject.Property("Release Script Name").Value;
            ReleaseScriptParam1 = screenObject.Property("Release Script Param 1").Value;
            ReleaseScriptParam2 = screenObject.Property("Release Script Param 2").Value;

            XPos = screenObject.Property("X").Value;
            YPos = screenObject.Property("Y").Value;

            Image.Tag = screenObject.Name;
            Image.ToolTip = Image.Tag;
            Image.MouseLeftButtonUp += new MouseButtonEventHandler(Click_Image_MouseLeftButtonUp);
            Image.MouseLeftButtonDown += new MouseButtonEventHandler(Click_Image_MouseLeftButtonDown);
            string imgName = screenObject.Property("Normal Image").Value;
            OSAEImage img = imgMgr.GetImage(imgName);

            if (img != null)
            {
                var imageStream = new MemoryStream(img.Data);
                var bitmapImage = new BitmapImage();

                bitmapImage.BeginInit();
                bitmapImage.StreamSource = imageStream;
                bitmapImage.EndInit();

                ImageWidth = bitmapImage.Width;
                ImageHeight = bitmapImage.Height;
                Image.Source = bitmapImage;
                Image.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                Image.Source = null;
                Image.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 44
0
        public Weather(OSAEObject sObj)
        {
            InitializeComponent();

            screenObject = sObj;

            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(timMain_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 30, 0);
            dispatcherTimer.Start();

            Load_All_Weather();
        }
        public StateImage(OSAEObject sObject)
        {
            InitializeComponent();

            screenObject = sObject;
            try
            {

                ObjectName = screenObject.Property("Object Name").Value;
                CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value;
                LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange;
                Image.ToolTip = ObjectName + "\n" + CurState + " since: " + LastStateChange;

                Image.Tag = ObjectName;
                Image.MouseLeftButtonUp += new MouseButtonEventHandler(State_Image_MouseLeftButtonUp);

                foreach (OSAEObjectProperty p in screenObject.Properties)
                {
                    if (p.Value.ToLower() == CurState.ToLower())
                    {
                        StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' '));
                    }
                }

                string imgName = screenObject.Property(StateMatch + " Image").Value;
                OSAEImage img = imgMgr.GetImage(imgName);

                if (img.Data != null)
                {
                    var imageStream = new MemoryStream(img.Data);
                    var bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = imageStream;
                    bitmapImage.EndInit();
                    Image.Source = bitmapImage;
                    Image.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    Image.Source = null;
                    Image.Visibility = System.Windows.Visibility.Hidden;
                }
            }
            catch (Exception ex)
            {

            }
        }
        public ParamInput(string ctlType, OSAEObject screenObject, string user)
        {
            InitializeComponent();
            currentUser = user;
            ctrlType = ctlType;
            if (ctrlType == "Method")
            {
                ObjectName = screenObject.Property("Object Name").Value; ;
                MethodName = screenObject.Property("Method Name").Value; ;
                Param1 = screenObject.Property("Param 1").Value; ;
                Param2 = screenObject.Property("Param 2").Value; ;
                if (Param1 == "[ASK]")
                {
                    inputParam1.Visibility = System.Windows.Visibility.Visible;
                    inputParam1Lab.Visibility = System.Windows.Visibility.Visible;
                    inputParam1.Text = Param1;
                }
                else
                {
                    inputParam1.Visibility = System.Windows.Visibility.Hidden;
                    inputParam1Lab.Visibility = System.Windows.Visibility.Hidden;
                }
                if (Param2 == "[ASK]")
                {
                    inputParam2.Visibility = System.Windows.Visibility.Visible;
                    inputParam2Lab.Visibility = System.Windows.Visibility.Visible;
                    inputParam2.Text = Param2;
                }
                else
                {
                    inputParam2.Visibility = System.Windows.Visibility.Hidden;
                    inputParam2Lab.Visibility = System.Windows.Visibility.Hidden;
                }
                BadInputLab.Visibility = System.Windows.Visibility.Visible;
                OKButt.IsEnabled = false;
                if (Param1 == "[ASK]")
                {
                    inputParam1.Focus();
                    inputParam1.SelectAll();
                }
                else
                {
                    inputParam2.Focus();
                    inputParam2.SelectAll();
                }
            }

            // TODO: use this for other parameter input
        }
Ejemplo n.º 47
0
        private void Load_All_Weather()
	    {
            weatherObj = OSAEObjectManager.GetObjectByName("Weather");
		    lblCurTemp.Content = weatherObj.Property("Temp").Value + "°";
		    lblConditions.Content = weatherObj.Property("Today Forecast").Value;
		    lblLastUpd.Content = weatherObj.Property("Last Updated").Value;

		    LoadLows();
		    LoadHighs();
		    LoadDayLabels();
		    LoadDaySummaryLabels();
		    LoadNightSummaryLabels();
		    LoadDates();
		    LoadImageControls();

            lblForcast.Text = "";
	    }
        public void createdevice(OSAEObject obj)
        {
            AndroidDevice d = new AndroidDevice(obj.Name, pName);

            foreach (OSAEObjectProperty prop in obj.Properties)
            {
                switch (prop.Name)
                {
                    case "Owner":
                        d.Owner = prop.Value;
                        break;
                    case "GCMID":
                        d.GCMID = prop.Value;
                        break;
                }
            }
            mdevices.Add(d);
            Log.Info("Added AndroidDevice to list: " + d.Name);
        }
        public StateImage(OSAEObject sObject)
        {
            InitializeComponent();

            screenObject = sObject;
            ObjectName = screenObject.Property("Object Name").Value;
            CurState = osae.GetObjectStateValue(ObjectName).Value;

            Image.Tag = ObjectName;
            Image.MouseLeftButtonUp += new MouseButtonEventHandler(State_Image_MouseLeftButtonUp);

            //ObjectStateTime = stateObject.LastUpd;

            string imgPath;
            foreach (ObjectProperty p in screenObject.Properties)
            {
                if (p.Value.ToLower() == CurState.ToLower())
                {
                    StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' '));
                }
            }

            imgPath = osae.APIpath + screenObject.Property(StateMatch + " Image").Value;

            if (File.Exists(imgPath))
            {
                byte[] byteArray = File.ReadAllBytes(imgPath);
                var imageStream = new MemoryStream(byteArray);
                var bitmapImage = new BitmapImage();

                bitmapImage.BeginInit();
                bitmapImage.StreamSource = imageStream;
                bitmapImage.EndInit();
                Image.Source = bitmapImage;
                Image.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                Image.Source = null;
                Image.Visibility = System.Windows.Visibility.Hidden;
            }
        }
 public VideoStreamViewer(string url, OSAEObject obj)
 {
     InitializeComponent();
     screenObject = obj;
     _mjpeg = new MjpegDecoder();
     _mjpeg.FrameReady += mjpeg_FrameReady;
     _mjpeg.Error += _mjpeg_Error;
     CamipAddress = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "IP Address").Value;
     CamPort = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Port").Value;
     UserName = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Username").Value;
     Password = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Password").Value;
     string streamURI = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
     if (streamURI == null)
     {
         this.Log.Info("Stream Path Not Found: " + streamURI);
         message.Content = "Can Not Open: " + streamURI;
     }
     else
     {
         streamURI = replaceFielddata(streamURI);
         _mjpeg.ParseStream(new Uri(streamURI));
     }
 }
 private void setPropertyValue(OSAEObject o, string p, string v)
 {
     if (OSAEObjectPropertyManager.ObjectPropertyExists(o.Name, p))
         o.SetProperty(p, v, Name);
     else
     {
         switch (p)
         {
             case propModel:
             case propDeviceaddr:
             case propProtocol:
             case propDevChgEvent:
             case propDevType:
                 // These properties are not mandatory, they can be removed, and plugin will work without them
                 logD("setPropertyValue", o.Name, "Property " + p + " does not exist, NOT updated.", o);
                 break;
             case propMinHum:
             case propMaxHum:
             case propMinTemp:
             case propMaxTemp:
             case propAvgHum:
             case propAvgTemp:
                 logW("setPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated.");
                 OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, p, "Float", "", "0", true);
                 o.SetProperty(p, v, Name);
                 break;
             case propDevId:
             case propLevel:
                 logW("setPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated.");
                 OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, p, "Integer", "", "", true);
                 o.SetProperty(p, v, Name);
                 break;
             case propMethods:
             case propLastCmd:
                 logW("setPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated.");
                 OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, p, "String", "", "", true);
                 o.SetProperty(p, v, Name);
                 break;
             case sensDTTemp:
                 logW("setPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated.");
                 OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, propTemp, "Float", "", "0", true);
                 o.SetProperty(p, v, Name);
                 break;
             case sensDTHum:
                 logW("setPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated.");
                 OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, propHum, "Float", "", "0", true);
                 o.SetProperty(p, v, Name);
                 break;
         }
     }
 }
        //public void decode_Lighting1()
        //{
        //    switch (recbuf(LIGHTING1.subtype))
        //    {
        //        case LIGHTING1.sTypeX10:
        //            logging.AddToLog("subtype       = X10");
        //            logging.AddToLog("Sequence nbr  = " + recbuf(LIGHTING1.seqnbr).ToString);
        //            logging.AddToLog("housecode     = " + Strings.Chr(recbuf(LIGHTING1.housecode)));
        //            logging.AddToLog("unitcode      = " + recbuf(LIGHTING1.unitcode).ToString);
        //            logging.AddToLog("Command       = ", false);
        //            switch (recbuf(LIGHTING1.cmnd))
        //            {
        //                case LIGHTING1.sOff:
        //                    logging.AddToLog("Off");
        //                    break;
        //                case LIGHTING1.sOn:
        //                    logging.AddToLog("On");
        //                    break;
        //                case LIGHTING1.sDim:
        //                    logging.AddToLog("Dim");
        //                    break;
        //                case LIGHTING1.sBright:
        //                    logging.AddToLog("Bright");
        //                    break;
        //                case LIGHTING1.sAllOn:
        //                    logging.AddToLog("All On");
        //                    break;
        //                case LIGHTING1.sAllOff:
        //                    logging.AddToLog("All Off");
        //                    break;
        //                case LIGHTING1.sChime:
        //                    logging.AddToLog("Chime");
        //                    break;
        //                default:
        //                    logging.AddToLog("UNKNOWN");
        //                    break;
        //            }
        //            break;
        //        case LIGHTING1.sTypeARC:
        //            logging.AddToLog("subtype       = ARC");
        //            logging.AddToLog("housecode     = " + Strings.Chr(recbuf(LIGHTING1.housecode)));
        //            logging.AddToLog("Sequence nbr  = " + recbuf(LIGHTING1.seqnbr).ToString);
        //            logging.AddToLog("unitcode      = " + recbuf(LIGHTING1.unitcode).ToString);
        //            logging.AddToLog("Command       = ", false);
        //            switch (recbuf(LIGHTING1.cmnd))
        //            {
        //                case LIGHTING1.sOff:
        //                    logging.AddToLog("Off");
        //                    break;
        //                case LIGHTING1.sOn:
        //                    logging.AddToLog("On");
        //                    break;
        //                case LIGHTING1.sAllOn:
        //                    logging.AddToLog("All On");
        //                    break;
        //                case LIGHTING1.sAllOff:
        //                    logging.AddToLog("All Off");
        //                    break;
        //                default:
        //                    logging.AddToLog("UNKNOWN");
        //                    break;
        //            }
        //            break;
        //        case LIGHTING1.sTypeAB400D:
        //            logging.AddToLog("subtype       = ELRO AB400");
        //            logging.AddToLog("Sequence nbr  = " + recbuf(LIGHTING1.seqnbr).ToString);
        //            logging.AddToLog("housecode     = " + Strings.Chr(recbuf(LIGHTING1.housecode)));
        //            logging.AddToLog("unitcode      = " + recbuf(LIGHTING1.unitcode).ToString);
        //            logging.AddToLog("Command       = ", false);
        //            switch (recbuf(LIGHTING1.cmnd))
        //            {
        //                case LIGHTING1.sOff:
        //                    logging.AddToLog("Off");
        //                    break;
        //                case LIGHTING1.sOn:
        //                    logging.AddToLog("On");
        //                    break;
        //                default:
        //                    logging.AddToLog("UNKNOWN");
        //                    break;
        //            }
        //            break;
        //        default:
        //            logging.AddToLog("ERROR: Unknown Sub type for Packet type=" + Conversion.Hex(recbuf(LIGHTING1.packettype)) + ": " + Conversion.Hex(recbuf(LIGHTING1.subtype)));
        //            break;
        //    }
        //    logging.AddToLog("Signal level  = " + (recbuf(LIGHTING1.rssi) >> 4).ToString());
        //}
        public void decode_Lighting2()
        {
            logging.AddToLog("Recieved Lighting2 Message.  Type: " + recbuf[(byte)LIGHTING2.subtype].ToString(), false);
            OSAEObject obj = new OSAEObject();

            switch (recbuf[(byte)LIGHTING2.subtype])
            {
                case (byte)LIGHTING2.sTypeAC:
                case (byte)LIGHTING2.sTypeHEU:
                case (byte)LIGHTING2.sTypeANSLUT:
                    //logging.AddToLog("id1: " + recbuf[(byte)LIGHTING2.id1].ToString(), true);
                    //logging.AddToLog("id2: " + recbuf[(byte)LIGHTING2.id2].ToString(), true);
                    //logging.AddToLog("id3: " + recbuf[(byte)LIGHTING2.id3].ToString(), true);
                    //logging.AddToLog("id4: " + recbuf[(byte)LIGHTING2.id4].ToString(), true);
                    //logging.AddToLog("uc: " + recbuf[(byte)LIGHTING2.unitcode].ToString(), true);

                    obj = OSAEObjectManager.GetObjectByAddress((recbuf[(byte)LIGHTING2.id1].ToString("X") +
                        "-" + recbuf[(byte)LIGHTING2.id2].ToString("X") +
                        "-" + recbuf[(byte)LIGHTING2.id3].ToString("X") +
                        "-" + recbuf[(byte)LIGHTING2.id4].ToString("X") +
                        "-" + recbuf[(byte)LIGHTING2.unitcode].ToString()));

                    switch (recbuf[(byte)LIGHTING2.subtype])
                    {
                        case (byte)LIGHTING2.sTypeAC:
                            logging.AddToLog("subtype       = AC", false);
                            break;
                        case (byte)LIGHTING2.sTypeHEU:
                            logging.AddToLog("subtype       = HomeEasy EU", false);
                            break;
                        case (byte)LIGHTING2.sTypeANSLUT:
                            logging.AddToLog("subtype       = ANSLUT", false);
                            break;
                    }
                    logging.AddToLog("Sequence nbr  = " + recbuf[(byte)LIGHTING2.seqnbr].ToString(), false);
                    //logging.AddToLog("ID - Unit            = " + address, false);
                    logging.AddToLog("Unit          = " + recbuf[(byte)LIGHTING2.unitcode].ToString(), false);
                    switch (recbuf[(byte)LIGHTING2.cmnd])
                    {
                        case (byte)LIGHTING2.sOff:
                            logging.AddToLog("Command       = Off", false);
                            OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", pName);
                            break;
                        case (byte)LIGHTING2.sOn:
                            logging.AddToLog("Command       = On", false);
                            OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", pName);
                            break;
                        case (byte)LIGHTING2.sSetLevel:
                            logging.AddToLog("Set Level:" + recbuf[(byte)LIGHTING2.level].ToString(), false);
                            break;
                        case (byte)LIGHTING2.sGroupOff:
                            logging.AddToLog("Group Off", false);
                            break;
                        case (byte)LIGHTING2.sGroupOn:
                            logging.AddToLog("Group On", false);
                            break;
                        case (byte)LIGHTING2.sSetGroupLevel:
                            logging.AddToLog("Set Group Level:" + recbuf[(byte)LIGHTING2.level].ToString(), false);
                            break;
                        default:
                            logging.AddToLog("UNKNOWN", false);
                            break;
                    }

                    break;
                default:
                    logging.AddToLog("ERROR: Unknown Sub type for Packet type=" + Convert.ToInt32(recbuf[(byte)LIGHTING2.packettype]) + ": " + Convert.ToInt32(recbuf[(byte)LIGHTING2.subtype]), false);
                    break;
            }
            logging.AddToLog("Signal level  = " + (recbuf[(byte)LIGHTING2.rssi] >> 4).ToString(), false);
        }
        //public void decode_Lighting3()
        //{
        //    switch (recbuf(LIGHTING3.subtype))
        //    {
        //        case LIGHTING3.sTypeKoppla:
        //            logging.AddToLog("subtype       = Ikea Koppla");
        //            logging.AddToLog("Sequence nbr  = " + recbuf(LIGHTING3.seqnbr).ToString);
        //            logging.AddToLog("Command       = ", false);
        //            switch (recbuf(LIGHTING3.cmnd))
        //            {
        //                case 0x0:
        //                    logging.AddToLog("Off");
        //                    break;
        //                case 0x1:
        //                    logging.AddToLog("On");
        //                    break;
        //                case 0x20:
        //                    logging.AddToLog("Set Level:" + recbuf(6).ToString);
        //                    break;
        //                case 0x21:
        //                    logging.AddToLog("Program");
        //                    break;
        //                default:
        //                    if (recbuf(LIGHTING3.cmnd) >= 0x10 & recbuf(LIGHTING3.cmnd) < 0x18)
        //                    {
        //                        logging.AddToLog("Dim");
        //                    }
        //                    else if (recbuf(LIGHTING3.cmnd) >= 0x18 & recbuf(LIGHTING3.cmnd) < 0x20)
        //                    {
        //                        logging.AddToLog("Bright");
        //                    }
        //                    else
        //                    {
        //                        logging.AddToLog("UNKNOWN");
        //                    }
        //                    break;
        //            }
        //            break;
        //        default:
        //            logging.AddToLog("ERROR: Unknown Sub type for Packet type=" + Conversion.Hex(recbuf(LIGHTING3.packettype)) + ": " + Conversion.Hex(recbuf(LIGHTING3.subtype)));
        //            break;
        //    }
        //    logging.AddToLog("Signal level  = " + (recbuf(LIGHTING3.rssi) >> 4).ToString());
        //}
        //public void decode_Lighting4()
        //{
        //    logging.AddToLog("Not implemented");
        //}
        public void decode_Lighting5()
        {
            logging.AddToLog("Recieved Lighting5 Message", false);
            OSAEObject obj = new OSAEObject();
            switch (recbuf[(byte)LIGHTING5.subtype])
            {
                case (byte)LIGHTING5.sTypeLightwaveRF:
                    obj = OSAEObjectManager.GetObjectByAddress("0" + recbuf[(byte)LIGHTING5.id1].ToString() + "-0" + recbuf[(byte)LIGHTING5.id2].ToString() + "-0" + recbuf[(byte)LIGHTING5.id3].ToString() + "-" + recbuf[(byte)LIGHTING5.unitcode].ToString());
                    logging.AddToLog("subtype       = LightwaveRF", false);
                    logging.AddToLog("Sequence nbr  = " + recbuf[(byte)LIGHTING5.seqnbr].ToString(), false);
                    logging.AddToLog("ID            = " + "0" + recbuf[(byte)LIGHTING5.id1].ToString() + "-0" + recbuf[(byte)LIGHTING5.id2] + "-0" + recbuf[(byte)LIGHTING5.id3].ToString(), false);
                    logging.AddToLog("Unit          = " + recbuf[(byte)LIGHTING5.unitcode].ToString(), false);
                    switch (recbuf[(byte)LIGHTING5.cmnd])
                    {
                        case (byte)LIGHTING5.sOff:
                            OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", pName);
                            logging.AddToLog("Command       = Off", false);
                            break;
                        case (byte)LIGHTING5.sOn:
                            OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", pName);
                            logging.AddToLog("Command       = On", false);
                            break;
                        case (byte)LIGHTING5.sGroupOff:
                            logging.AddToLog("Command       = Group Off", false);
                            break;
                        case (byte)LIGHTING5.sMood1:
                            logging.AddToLog("Command       = Group Mood 1", false);
                            break;
                        case (byte)LIGHTING5.sMood2:
                            logging.AddToLog("Command       = Group Mood 2", false);
                            break;
                        case (byte)LIGHTING5.sMood3:
                            logging.AddToLog("Command       = Group Mood 3", false);
                            break;
                        case (byte)LIGHTING5.sMood4:
                            logging.AddToLog("Command       = Group Mood 4", false);
                            break;
                        case (byte)LIGHTING5.sMood5:
                            logging.AddToLog("Command       = Group Mood 5", false);
                            break;
                        case (byte)LIGHTING5.sUnlock:
                            logging.AddToLog("Command       = Unlock", false);
                            break;
                        case (byte)LIGHTING5.sLock:
                            logging.AddToLog("Command       = Lock", false);
                            break;
                        case (byte)LIGHTING5.sAllLock:
                            logging.AddToLog("Command       = All lock", false);
                            break;
                        case (byte)LIGHTING5.sClose:
                            logging.AddToLog("Command       = Close inline relay", false);
                            break;
                        case (byte)LIGHTING5.sStop:
                            logging.AddToLog("Command       = Stop inline relay", false);
                            break;
                        case (byte)LIGHTING5.sOpen:
                            logging.AddToLog("Command       = Open inline relay", false);
                            break;
                        case (byte)LIGHTING5.sSetLevel:
                            logging.AddToLog("Command       = Set dim level to: " + Convert.ToInt32((recbuf[(byte)LIGHTING5.level] * 3.2)).ToString() + "%", false);
                            break;
                        default:
                            logging.AddToLog("UNKNOWN", false);
                            break;
                    }

                    break;
                case (byte)LIGHTING5.sTypeEMW100:
                    obj = OSAEObjectManager.GetObjectByAddress("0" + recbuf[(byte)LIGHTING5.id1].ToString() + "-0" + recbuf[(byte)LIGHTING5.id2].ToString() + "-" + recbuf[(byte)LIGHTING5.unitcode].ToString());
                    logging.AddToLog("subtype       = EMW100", false);
                    logging.AddToLog("Sequence nbr  = " + recbuf[(byte)LIGHTING5.seqnbr].ToString(), false);
                    logging.AddToLog("ID            = " + "0" + recbuf[(byte)LIGHTING5.id1].ToString() + "-0" + recbuf[(byte)LIGHTING5.id2].ToString(), false);
                    logging.AddToLog("Unit          = " + recbuf[(byte)LIGHTING5.unitcode].ToString(),false);
                    switch (recbuf[(byte)LIGHTING5.cmnd])
                    {
                        case (byte)LIGHTING5.sOff:
                            OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", pName);
                            logging.AddToLog("Command       = Off", false);
                            break;
                        case (byte)LIGHTING5.sOn:
                            OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", pName);
                            logging.AddToLog("Command       = On", false);
                            break;
                        case (byte)LIGHTING5.sLearn:
                            logging.AddToLog("Command       = Learn", false);
                            break;
                        default:
                            logging.AddToLog("Command       = UNKNOWN", false);
                            break;
                    }

                    break;
                default:
                    logging.AddToLog("ERROR: Unknown Sub type for Packet type=" + recbuf[(byte)LIGHTING5.packettype].ToString() + ": " + recbuf[(byte)LIGHTING5.subtype].ToString(), false);
                    break;
            }
            logging.AddToLog("Signal level  = " + (recbuf[(byte)LIGHTING5.rssi] >> 4).ToString(), false);
        }
Ejemplo n.º 54
0
        public StateImage(OSAEObject sObject)
        {
            InitializeComponent();

            screenObject = sObject;
          //  try
          //  {

                ObjectName = screenObject.Property("Object Name").Value;
                SliderMethod = screenObject.Property("Slider Method").Value;
                CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value;
              
                LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange;
                Image.ToolTip = ObjectName + "\n" + CurState + " since: " + LastStateChange;

                Image.Tag = ObjectName;
                Image.MouseLeftButtonUp += new MouseButtonEventHandler(State_Image_MouseLeftButtonUp);

                foreach (OSAEObjectProperty p in screenObject.Properties)
                {
                    if (p.Value.ToLower() == CurState.ToLower())
                    {
                        StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' '));
                    }
                }

                string imgName = screenObject.Property(StateMatch + " Image").Value;
                string imgName2 = screenObject.Property(StateMatch + " Image 2").Value;
                string imgName3 = screenObject.Property(StateMatch + " Image 3").Value;
                string imgName4 = screenObject.Property(StateMatch + " Image 4").Value;
                try
                {
                    repeatAnimation = Convert.ToBoolean(screenObject.Property("Repeat Animation").Value);
                }
                catch (Exception ex)
                {
                    OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Repeat Animation", "TRUE", "GUI");
                    repeatAnimation = true;
                }
                try
                {
                    frameDelay = Convert.ToInt16(screenObject.Property("Frame Delay").Value);
                }
                catch (Exception ex)
                {
                    frameDelay = 100;
                    OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Frame Delay", "100", "GUI");
                }
                img1 = imgMgr.GetImage(imgName);
                if (img1 != null)
                {
                    var imageStream = new MemoryStream(img1.Data);
                    var bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = imageStream;
                    bitmapImage.EndInit();

                    Image.Source = bitmapImage;
                    Image.Visibility = System.Windows.Visibility.Visible;
                    
                    imageFrames = 1;
                    currentFrame = 1;
                }
                else
                {
                    Image.Source = null;
                    Image.Visibility = System.Windows.Visibility.Hidden;
                }

                sliderVisible = Convert.ToBoolean(screenObject.Property("Show Slider").Value);

                if (sliderVisible)
                {
                    sldSlider.Visibility = System.Windows.Visibility.Visible;
                    CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value;
                    sldSlider.Value = Convert.ToUInt16( CurLevel);
                }

                else
                    sldSlider.Visibility = System.Windows.Visibility.Hidden;

                // Primary Frame is loaded, load up additional frames for the time to display.
                img2 = imgMgr.GetImage(imgName2);
                if (img2 != null)
                    imageFrames = 2;
                img3 = imgMgr.GetImage(imgName3);
                if (img3 != null)
                    imageFrames = 3;
                img4 = imgMgr.GetImage(imgName4);
                if (img4 != null)
                    imageFrames = 4;
        //    }
         //   catch (Exception ex)
         //   {
         //       MessageBox.Show(ex.Message, "StateImage Load");
          //  }

            timer.Interval = TimeSpan.FromMilliseconds(frameDelay);
            timer.Tick += this.timer_Tick;

            if (imageFrames > 1) timer.Start();
        }
        public PropertyLabel(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            ObjectName = screenObject.Property("Object Name").Value;
            PropertyName = screenObject.Property("Property Name").Value;

            string sPropertyValue;
            if (string.Equals(PropertyName, "STATE", StringComparison.CurrentCultureIgnoreCase))
            {
                sPropertyValue = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value;
            }
            else
            {
                sPropertyValue = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, PropertyName).Value;
            }
            string sBackColor = screenObject.Property("Back Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string sPrefix = screenObject.Property("Prefix").Value;
            string sSuffix = screenObject.Property("Suffix").Value;
            string iFontSize = screenObject.Property("Font Size").Value;
            string sFontName = screenObject.Property("Font Name").Value;

            if (sPropertyValue != "")
            {
                if (sBackColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                        propLabel.Background = brush;
                    }
                    catch (Exception)
                    {
                    }
                }
                if (sForeColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                        propLabel.Foreground = brush;
                    }
                    catch (Exception)
                    {
                    }
                }
                if (iFontSize != "")
                {
                    try
                    {
                        propLabel.FontSize = Convert.ToDouble(iFontSize);
                    }
                    catch (Exception)
                    {
                    }
                }
                propLabel.Content = sPrefix + sPropertyValue + sSuffix;
            }
            else
            {
                propLabel.Content = "";
            }
        }
        public TimerLabel(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            screenName = Name;

            ObjectName = screenObject.Property("Object Name").Value;

            OSAEObjectState os = OSAEObjectStateManager.GetObjectStateValue(ObjectName);
            CurrentState = os.Value;

            OffTimer = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName,"OFF TIMER").Value);
            TimeInState = (int)os.TimeInState;

            string sValue;
            string sBackColor = screenObject.Property("Back Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string iFontSize = screenObject.Property("Font Size").Value;
            string sFontName = screenObject.Property("Font Name").Value;

            if (CurrentState == "OFF")
                sValue = os.StateLabel;
            else
            {
                span = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
                sValue = span.ToString(@"mm\:ss");
            }

            if (sValue != "")
            {
                if (sBackColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                        timerLabel.Background = brush;
                    }
                    catch
                    {
                    }
                }
                if (sForeColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                        timerLabel.Foreground = brush;
                    }
                    catch
                    {
                    }
                }
                if (iFontSize != "")
                {
                    try
                    {
                        timerLabel.FontSize = Convert.ToDouble(iFontSize);
                    }
                    catch
                    {
                    }
                }
                timerLabel.Content = sValue;
            }
            else
            {
                timerLabel.Content = "";
            }
            timer.Interval = 1000;
            timer.Enabled = true;
            timer.Elapsed += new ElapsedEventHandler(timer_tick);
        }
 private void setOSAProperties(OSAEObject o, int deviceId)
 {
     try { int Methods = TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_ALL); }
     catch { logW("setOSAProperties", o.Name, "Problem when reading Methods."); }
     setPropertyValue(o, propDevId, deviceId.ToString());
     setPropertyValue(o, propModel, TelldusNETWrapper.tdGetModel(deviceId));
     setPropertyValue(o, propDevType, deviceTypeToString(TelldusNETWrapper.tdGetDeviceType(deviceId)));
     setPropertyValue(o, propProtocol, TelldusNETWrapper.tdGetProtocol(deviceId));
     try { setMethods(deviceId, o); }
     catch { logW( "setOSAProperties", o.Name, propMethods + " Problem when setting property."); }
     setPropertyValue(o, propDeviceaddr, TelldusNETWrapper.tdGetDeviceParameter(deviceId, "house", "") + "/" + TelldusWrapper.TelldusNETWrapper.tdGetDeviceParameter(deviceId, "code", "") + "/" + TelldusWrapper.TelldusNETWrapper.tdGetDeviceParameter(deviceId, "unit", ""));
 }
 //static?
 private void StatusDefault(OSAEObject o)
 {
     if (o.Name!=Name)           //Do not change the state of the plugin object!
         switch (o.Type)
         {
             case objTypeHum:
             case objTypeTemp:
             case objTypeTempHum:
                 o.SetState(objStatOff);
                 //sensor s = new sensor();
                 //sensorList.Add(int.Parse(o.Property(propDevId).Value), s);
                 break;
             default:
                 o.SetState(objStatUnKnown);
                 break;
         }
 }
        public StateImage(OSAEObject sObject, string appName)
        {
            InitializeComponent();

            OSAEImageManager imgMgr = new OSAEImageManager();
            gAppName = appName;
            screenObject = sObject;
            ObjectName = screenObject.Property("Object Name").Value;
            LinkedObject = OSAEObjectManager.GetObjectByName(ObjectName);
            SliderMethod = screenObject.Property("Slider Method").Value;
            CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value;
            CurStateLabel = OSAEObjectStateManager.GetObjectStateValue(ObjectName).StateLabel;
            try
            {
                string propertyCheck = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value;
                if (propertyCheck != "") LightLevel = Convert.ToUInt16(propertyCheck);
                else LightLevel = 100;
            }
            catch
            { }

            LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange;
            Image.ToolTip = ObjectName + " " + CurStateLabel + "\n" + "since: " + LastStateChange;

            Image.Tag = ObjectName;
            Image.MouseLeftButtonUp += new MouseButtonEventHandler(State_Image_MouseLeftButtonUp);

            foreach (OSAEObjectProperty p in screenObject.Properties)
            {
                if (p.Value.ToLower() == CurState.ToLower())
                    StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' '));
            }

            try
            {
                string imgName = screenObject.Property(StateMatch + " Image").Value;
                string imgName2 = screenObject.Property(StateMatch + " Image 2").Value;
                string imgName3 = screenObject.Property(StateMatch + " Image 3").Value;
                string imgName4 = screenObject.Property(StateMatch + " Image 4").Value;

                try
                { repeatAnimation = Convert.ToBoolean(screenObject.Property("Repeat Animation").Value); }
                catch
                {
                    OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Repeat Animation", "TRUE", gAppName);
                    repeatAnimation = true;
                }

                try
                { frameDelay = Convert.ToInt16(screenObject.Property("Frame Delay").Value); }
                catch
                {
                    frameDelay = 100;
                    OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Frame Delay", "100", gAppName);
                }
                OSAEImage img1 = imgMgr.GetImage(imgName);
                if (img1.Type == "gif")
                {
                    ms1 = new MemoryStream(img1.Data);
                    BitmapImage bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms1;
                    bitmapImage.EndInit();

                    //Image.Source = bitmapImage;
                    ImageWidth = bitmapImage.Width;
                    ImageHeight = bitmapImage.Height;
                    ImageBehavior.SetAnimatedSource(Image, bitmapImage);

                    Image.Visibility = System.Windows.Visibility.Visible;
                }
                else if (img1 != null)
                {
                    ms1 = new MemoryStream(img1.Data);
                    BitmapImage bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms1;
                    bitmapImage.EndInit();

                    Image.Source = bitmapImage;
                    ImageWidth = bitmapImage.Width;
                    ImageHeight = bitmapImage.Height;

                    Image.Visibility = System.Windows.Visibility.Visible;

                    imageFrames = 1;
                    currentFrame = 1;
                    OSAEImage img2 = imgMgr.GetImage(imgName2);
                    if (img2 != null)
                    {
                        ms2 = new MemoryStream(img2.Data);
                        imageFrames = 2;
                        OSAEImage img3 = imgMgr.GetImage(imgName3);
                        if (img3 != null)
                        {
                            ms3 = new MemoryStream(img3.Data);
                            imageFrames = 3;
                            OSAEImage img4 = imgMgr.GetImage(imgName4);
                            if (img4 != null)
                            {
                                ms4 = new MemoryStream(img4.Data);
                                imageFrames = 4;
                            }
                        }
                    }
                }
                else
                {
                    Image.Source = null;
                    Image.Visibility = System.Windows.Visibility.Hidden;
                }
            }
            catch { }

            sliderVisible = Convert.ToBoolean(screenObject.Property("Show Slider").Value);

            if (sliderVisible)
            {
                sldSlider.Visibility = System.Windows.Visibility.Visible;
                try
                {
                    CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value;
                    sldSlider.Value = Convert.ToUInt16(CurLevel);
                }
                catch { }
            }
            else
                sldSlider.Visibility = System.Windows.Visibility.Hidden;

            timer.Interval = TimeSpan.FromMilliseconds(frameDelay);
            timer.Tick += this.timer_Tick;

            if (imageFrames > 1) timer.Start();
        }
        private int doCommand(OSAEObject o, string addr, OSAEMethod method)
        {
            try
            {
                int deviceId = System.Convert.ToInt32(addr);
                int result = 0;
                if ((o.State.Value.ToUpper() != objStatDisable) || (method.MethodName.ToUpper() == objMtdEnable) ||
                     (o.Name == Name && method.MethodName.ToUpper() == objMtdInit))
                {
                    switch (method.MethodName)
                    {
                        case objMtdBell:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_BELL) > 0)
                            {
                                result = TelldusNETWrapper.tdBell(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.TELLSTICK_BELL);
                            }
                            else
                                logW("doCommand", o.Name, objMtdBell + " Method is not supported on this object.");
                            break;
                        case objMtdDim:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_DIM) > 0)
                            {
                                try
                                {
                                    result = TelldusNETWrapper.tdDim(deviceId, (char)((Int32)(Double.Parse(method.Parameter1) * (255 / 100.0))));
                                }
                                catch (Exception)
                                {
                                    result = TelldusNETWrapper.tdDim(deviceId, '0');
                                }
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdDim + " Method is not supported on this object.");
                            break;
                        case objMtdDown:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_DOWN) > 0)
                            {
                                result = TelldusNETWrapper.tdDown(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdDown + " Method is not supported on this object.");
                            break;
                        case objMtdUp:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_UP) > 0)
                            {
                                result = TelldusNETWrapper.tdUp(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdUp + " Method is not supported on this object.");
                            break;
                        case objMtdStop:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_STOP) > 0)
                            {
                                result = TelldusNETWrapper.tdStop(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdStop + " Method is not supported on this object.");
                            break;
                        case objMtdOn:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_TURNON) > 0)
                            {
                                result = TelldusNETWrapper.tdTurnOn(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdOn + " Method is not supported on this object.");
                            break;
                        case objMtdOff:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_TURNOFF) > 0)
                            {
                                result = TelldusNETWrapper.tdTurnOff(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdOff + " Method is not supported on this object.");
                            break;
                        case objMtdToggle:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_TOGGLE) > 0)
                            {
                                result = TelldusNETWrapper.TELLSTICK_ERROR_METHOD_NOT_SUPPORTED; // !!!!!!!
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdToggle + " Method is not supported on this object.");
                            break;
                        case objMtdExecute:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_EXECUTE) > 0)
                            {
                                result = TelldusNETWrapper.tdExecute(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdExecute + " Method is not supported on this object.");
                            break;
                        case objMtdLearn:
                            if (TelldusNETWrapper.tdMethods(deviceId, TelldusNETWrapper.TELLSTICK_LEARN) > 0)
                            {
                                result = TelldusNETWrapper.tdLearn(deviceId);
                                logResult(method.MethodName, result, o);
                                setLastProperties(o, deviceId, TelldusNETWrapper.tdLastSentCommand(deviceId, TelldusNETWrapper.TELLSTICK_ALL));
                            }
                            else
                                logW("doCommand", o.Name, objMtdLearn + " Method is not supported on this object.");
                            break;
                        case objMtdRestMaxMin:
                            switch (o.Type)
                            {
                                case objTypeHum:
                                    setPropertyValue(o, propMaxHum, o.Property(propHum).Value);
                                    setPropertyValue(o, propMinHum, o.Property(propHum).Value);
                                    log("doCommand", o.Name, " Reset Min/Max values.");
                                    break;
                                case objTypeTemp:
                                    setPropertyValue(o, propMaxTemp, o.Property(propTemp).Value);
                                    setPropertyValue(o, propMinTemp, o.Property(propTemp).Value);
                                    log("doCommand", o.Name, " Reset Min/Max values.");
                                    break;
                                case objTypeTempHum:
                                    setPropertyValue(o, propMaxHum, o.Property(propHum).Value);
                                    setPropertyValue(o, propMinHum, o.Property(propHum).Value);
                                    setPropertyValue(o, propMaxTemp, o.Property(propTemp).Value);
                                    setPropertyValue(o, propMinTemp, o.Property(propTemp).Value);
                                    log("doCommand", o.Name, " Reset Min/Max values.");
                                    break;
                                default:
                                    logE("doCommand", o.Name, " Reset Min/Max values.", null);
                                    break;
                            }
                            break;

                        case objMtdEnable:
                            switch (o.Type)
                            {
                                case objTypeHum:
                                case objTypeTemp:
                                case objTypeTempHum:
                                    o.SetState(objStatOff);
                                    log("doCommand", o.Name, objStatOff + " Device state set on object.");
                                    break;
                                default:
                                    o.SetState(objStatUnKnown);
                                    log("doCommand", o.Name, objStatUnKnown + " Device state set on object.");
                                    break;
                            }
                            break;
                        case objMtdDis:
                            o.SetState(objStatDisable);  // Should be done automatically on method with same name as state, but not working
                            log("doCommand", o.Name, objStatDisable + " Device state set on object.");
                            break;
                        case objMtdDebugOn:
                            if (debug != true)
                            {
                                debug = true;
                                log("doCommand", o.Name, "Method DebugOn, set debug to TRUE.");
                            }
                            else
                                log("doCommand", o.Name, "Method DebugOn, debug already set to TRUE.");
                            break;
                        case objMtdDebugOff:
                            if (debug != false)
                            {
                                debug = false;
                                log("doCommand", o.Name, "Method DebugOff, set debug to FALSE.");
                            }
                            else
                                log("doCommand", o.Name, "Method DebugOff, debug already set to FALSE.");
                            break;
                        default:
                            logE("doCommand", o.Name, method.MethodName + "Unsuported method: ", null);
                            break;
                        case objMtdRestore:
                            switch (o.Type)
                            {
                                case objTypeBell:
                                    restoreTellstickBellObjectType(Name);
                                    break;
                                case objTypeDim:
                                    restoreTellstickMultiLevelswitchObjectType(Name);
                                    break;
                                case objTypeGroup:
                                    restoreTellstickGroupDeviceObjectType(Name);
                                    break;
                                case objTypeHum:
                                    restoreTellstickHumiditySensorObjectType(Name);
                                    break;
                                case objTypeOnOff:
                                    restoreTellstickBinarySwitchObjectType(Name);
                                    break;
                                case objTypeTemp:
                                    restoreTellstickTemperatureSensorObjectType(Name);
                                    break;
                                case objTypeTempHum:
                                    restoreTellstickTempHumiditySensorObjectType(Name);
                                    break;
                                case objTypeUpDown:
                                    restoreUpDownDeviceObjectType(Name);
                                    break;
                            }
                            break;
                    }
                } // if
                else
                    logW("doCommand", o.Name, objStatDisable + " Methods can not be used when object state is DISABLE!");
                return result;
            }
            catch (Exception ex)
            {
                logE("doCommand", "", "Exception in doCommand: ", ex);
                return -1;
            }
        }