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)); } }
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; } }
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; } }
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 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); }
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 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 override void ProcessCommand(OSAEMethod method) { this.Log.Info("RECEIVED: " + method.ObjectName + " - " + method.MethodName); sMethod = method.MethodName; camName = method.ObjectName; camobj = OSAEObjectManager.GetObjectByName(camName); if (sMethod == "SNAPSHOT") { string i = DateTime.Now.ToLongTimeString(); string j = DateTime.Now.ToShortDateString(); i = i.Replace(":", "_"); j = j.Replace("/", "_"); i = j + "_" + i; i = i.Replace(" ", ""); try { string camSnapShot = camobj.Property("camSnapShot").Value; string camSloc = camobj.Property("Save Location").Value; camSloc = camSloc + @"\"; string filename = camSloc + camName + "_" + i + ".jpg"; var URI = new Uri(renameingSys(camSnapShot, "", "")); WebClient wc = new WebClient(); wc.Headers["Content-Type"] = "application/x-www-form-urlencoded"; wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCallback2); wc.DownloadFile(URI, filename); this.Log.Info(filename + " was created"); } catch (Exception ex) { this.Log.Error("An error occurred durning the snapshot!!!: " + ex.Message); } } else { try { WebClient wc = new WebClient(); sProperty = camobj.Property(sMethod).Value.ToString(); wc.Headers["Content-Type"] = "application/x-www-form-urlencoded"; wc.UploadStringCompleted += new UploadStringCompletedEventHandler(UploadStringCallback2); sProperty = renameingSys(sProperty, method.Parameter1, method.Parameter2); wc.UploadStringAsync(new Uri(sProperty), "POST", ""); this.Log.Info("SENT TO: " + method.ObjectName + ": " + sProperty); } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); } } this.Log.Info("==================================================="); }
private void Load_All_Weather() { weatherObj = OSAEObjectManager.GetObjectByName("Weather"); lblCurTemp.Text = weatherObj.Property("Temp").Value + "°"; lblConditions.Text = weatherObj.Property("Conditions").Value; lblLastUpd.Text = weatherObj.Property("Last Updated").Value; LoadLows(); LoadHighs(); LoadDayLabels(); LoadDaySummaryLabels(); LoadNightSummaryLabels(); LoadDates(); LoadImageControls(); }
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 }
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 }
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 = ""; } }
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 = ""; } }
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; } }
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."); } } } }
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; }
protected void Page_Load(object sender, EventArgs e) { OSAEObject obj = OSAEObjectManager.GetObjectByName(screenObject.Property("Object Name").Value); streamURI = renameingSys(obj.Property("Stream Address").Value); double imgWidth = Convert.ToDouble(obj.Property("Width").Value); double imgHeight = Convert.ToDouble(obj.Property("Height").Value); ControlWidth = Convert.ToDouble(screenObject.Property("Width").Value); imgRatio = ControlWidth / imgWidth; ControlHeight = Convert.ToInt32(imgHeight * imgRatio); width = ControlWidth.ToString(); height = ControlHeight.ToString(); vidPlayer.ImageUrl = streamURI; vidPlayer.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() + ";"); }
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); } } } } }
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; } }
private void Load_All_Weather() { weatherObj = OSAEObjectManager.GetObjectByName("Weather"); lblCurTemp.Content = weatherObj.Property("Temp").Value + "°"; lblConditions.Content = weatherObj.Property("Today Forecast").Value; LoadLows(); LoadHighs(); LoadDayLabels(); LoadDaySummaryLabels(); LoadNightSummaryLabels(); LoadDates(); LoadImageControls(); lblForcast.Text = ""; }
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 = ""; }
protected void Page_Load(object sender, EventArgs e) { OSAEObject obj = OSAEObjectManager.GetObjectByName(screenObject.Property("Object Name").Value); Source = renameingSys(obj.Property("SNAP SHOT").Value); double imgWidth = Convert.ToDouble(obj.Property("Width").Value); double imgHeight = Convert.ToDouble(obj.Property("Height").Value); ControlWidth = Convert.ToDouble(screenObject.Property("Width").Value); imgRatio = ControlWidth / imgWidth; ControlHeight = Convert.ToInt32(imgHeight * imgRatio); width = ControlWidth.ToString(); height = ControlHeight.ToString(); imgSnapShot.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() + ";"); imgSnapShot.ImageUrl = @Source; imgSnapShot.Width = System.Web.UI.WebControls.Unit.Parse(width); imgSnapShot.Height = System.Web.UI.WebControls.Unit.Parse(height); }
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 BrowserFrame(OSAEObject sObject) { InitializeComponent(); screenObject = sObject; try { Uri uriproperty = new Uri(screenObject.Property("URI").Value); wbBrowser.Source = uriproperty; } catch { } }
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)); } }
// Add any additional properties needed here... #endregion #region Constructor // Code to Initialize your custom User Control public CustomUserControl(OSAEObject sObj, string ControlName, string appName, string user) { InitializeComponent(); gAppName = appName; currentUser = user; _controlname = ControlName; screenObject = sObj; objName = sObj.Property("Object Name").Value; CurState = OSAEObjectStateManager.GetObjectStateValue(objName).Value; LastStateChange = OSAEObjectStateManager.GetObjectStateValue(objName).LastStateChange; // Retreive any other information needed from the database here.... // Execute the refreshControl function. See below! refreshControl(); }
public override void RunInterface(string pluginName) { //throw new NotImplementedException(); this.Log.Info("Found Plugin Object: " + pluginName); this.Log.Info(pluginName + " is starting..."); OSAEObject plugin = OSAEObjectManager.GetObjectByName(pluginName); string refresh = plugin.Property("Refresh").Value; int refre = Convert.ToInt16(refresh); Onlineupdatetime = Onlineupdatetime * refre; OnlineUpdateTimer = new System.Timers.Timer(); OnlineUpdateTimer.Interval = Onlineupdatetime; OnlineUpdateTimer.Start(); OnlineUpdateTimer.Elapsed += new ElapsedEventHandler(OnlineUpdateTime); this.updateOnlineThread = new Thread(new ThreadStart(updateonline)); this.updateOnlineThread.Start(); Thread.Sleep(5000); }
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) { // Success, create non-persistent authentication cookie. FormsAuthentication.SetAuthCookie( this.txtUserName.Text.Trim(), false); FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket(this.txtUserName.Text.Trim(), true, 10); HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1)); Response.Cookies.Add(cookie1); // 4. Do the redirect. String returnUrl1; // the login is successful if (Request.QueryString["ReturnUrl"] == null) { returnUrl1 = "objects.aspx"; } //login not unsuccessful else { returnUrl1 = Request.QueryString["ReturnUrl"]; } Response.Redirect(returnUrl1); } else { lblError.Visible = true; } } lblError.Visible = true; }
/// This method is only available when a "ChannelUp" method also exist! // Will not be available on STR devices public void setchannel(OSAEMethod method) { 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.GetRemoteCommandList(); string channel = method.Parameter1; try { mySonyDevice.ChannelSet(channel); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Current_Channel", channel, "Sony"); this.Log.Info("Executed: " + mySonyDevice.Name + " - Set Channel to: " + channel); } catch (Exception ex) { this.Log.Error("Set Channel Method: Error occurred!!!: " + ex.Message); } }
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.ToInt16(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); }
public bool registerCheck(OSAEMethod method) { try { if (CheckObjByName(objName)) { objName = method.ObjectName; sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.initialize(sonyobj.Name, sonyobj.Property("Host").Value, sonyobj.Property("Port").Value, sonyobj.Property("Mac").Value); mySonyReg = mySonyDevice.register(mySonyDevice.Mac, "OSAE_Sony_Plugin"); if (mySonyReg == true) { this.Log.Info("Setting State for : " + mySonyDevice.Name + " to Online."); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "ON", "Sony Plugin"); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Online", "TRUE", "Sony Plugin"); } else { this.Log.Info("The Sony device: " + mySonyDevice.Name + ", did not respond!"); this.Log.Info("Setting State for : " + mySonyDevice.Name + " to Offline."); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Online", "FALSE", "Sony Plugin"); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "OFF", "Sony Plugin"); this.Log.Debug("Make sure the Device is ON before running any Methods for any Sony Device!"); this.Log.Debug("If you continue to have issues, set the Registered Property to FALSE and re-run the REGISTER method for this device."); } } else { this.Log.Error("The Sony plugin did NOT find the object: " + objName); this.Log.Debug("The object " + objName + " Must be Powered ON!"); } } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); this.Log.Debug("The Sony Register Check was unsuccessful."); } return mySonyReg; }
public void registerDevice(OSAEMethod method) { try { if (CheckObjByName(objName)) { sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.initialize(sonyobj.Name, sonyobj.Property("Host").Value, sonyobj.Property("Port").Value, sonyobj.Property("Mac").Value); if (sonyobj.Property("Registered").Value == "FALSE") { mySonyReg = mySonyDevice.register(mySonyDevice.Mac, "OSAE.Sony"); if (mySonyReg == true) { OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Registered", "TRUE", "Sony Plugin"); this.Log.Info("The Sony Device : " + mySonyDevice.Name + " was registered Successfully."); sonyobj = OSAEObjectManager.GetObjectByName(objName); } else { this.Log.Error("The Sony Registered Method did NOT complete. See Debug Messages.."); this.Log.Debug("Make sure the Device is ON before running the Register Method for any Sony Device!"); this.Log.Debug("You may need to go to the device and respond to the registration process!"); this.Log.Debug("Registration returned: " + mySonyReg.ToString() + " for Mac: " + mySonyDevice.Mac); } } if (sonyobj.Property("Registered").Value == "TRUE") { mySonyReg = mySonyDevice.register(mySonyDevice.Mac, "OSAE_Sony_Plugin"); if (mySonyReg == true) { this.Log.Info("Setting State for : " + mySonyDevice.Name + " to Online."); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "ON", "Sony Plugin"); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Online", "TRUE", "Sony Plugin"); } else { this.Log.Info("The Sony device: " + mySonyDevice.Name + ", did not respond!"); this.Log.Info("Setting State for : " + mySonyDevice.Name + " to Offline."); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Online", "FALSE", "Sony Plugin"); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "OFF", "Sony Plugin"); this.Log.Debug("Make sure the Device is ON before running any Methods for any Sony Device!"); this.Log.Debug("If you continue to have issues, set the Registered Property to FALSE and re-run the REGISTER method for this device."); } } } else { this.Log.Error("The Sony Register Method did NOT find the object: " + objName); this.Log.Debug("The object " + objName + " was not found"); } } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); } }
public void retrieveDeviceCmd(OSAEMethod method) { if (CheckObjByName(objName)) { string CmdList = ""; objName = method.ObjectName; sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.initialize(sonyobj.Name, sonyobj.Property("Host").Value, sonyobj.Property("Port").Value, sonyobj.Property("Mac").Value); try { CmdList = mySonyDevice.get_remote_command_list(); this.Log.Debug("The Sony plugin successfully retieved the CmdList."); } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); this.Log.Debug("The Sony plugin did NOT retieve the Command List from " + mySonyDevice.Name); } if (CmdList == "") { this.Log.Error("The Sony Retrieve Method for device " + mySonyDevice.Name + "Was Unsuccessful."); } else { this.Log.Info("Reading XML information retrieved from: " + mySonyDevice.Name); DataSet CommandList = new DataSet(); System.IO.StringReader xmlSR = new System.IO.StringReader(CmdList); CommandList.ReadXml(xmlSR, XmlReadMode.Auto); DataTable IRCCcmd = new DataTable(); IRCCcmd = CommandList.Tables[0]; foreach (DataRow results in IRCCcmd.Rows) { string cName = results.Field<string>("name"); string cValue = results.Field<string>("value"); string cType = results.Field<string>("type"); if (cType == "ircc") { OSAEObjectTypeManager.ObjectTypeMethodAdd(cName.ToUpper(), cName, mySonyDevice.Name, "", "", "", ""); //OSAEObjectTypeManager.ObjectTypePropertyAdd(cName.ToUpper(), "String", cValue, mySonyDevice.Name, false); this.Log.Info("Created Method: " + cName + " for device " + mySonyDevice.Name); } } OSAEObjectTypeManager.ObjectTypeMethodAdd("SETCHANNEL", "Set Channel", mySonyDevice.Name, "Channel #", "", "", ""); this.Log.Info("Created Method: Set Channel for device " + mySonyDevice.Name); } } else { this.Log.Error("The Sony Retrieve Method did NOT find the object: " + objName); this.Log.Debug("The object " + objName + " Must be Powered ON and Registered!"); } }
public bool checkStatus(OSAEMethod method) { try { objName = method.ObjectName; if (CheckObjByName(objName)) { sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.Name = sonyobj.Name; mySonyDevice.DocumentUrl = sonyobj.Property("DocumentURL").Value; mySonyDevice.ServerName = "OSAE.Sony"; bool OK = mySonyDevice.BuildFromDocument(new Uri(mySonyDevice.DocumentUrl)); curStatus = mySonyDevice.CheckStatus(); if (OK == false) { curStatus = ""; } if (curStatus != "") { this.Log.Info("Setting State for : " + mySonyDevice.Name + " to Online."); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "ON", "Sony"); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Online", "TRUE", "Sony"); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Current_Status", curStatus, "Sony"); mySonyReg = true; int cV = mySonyDevice.RenderingControl.GetVolume(mySonyDevice); string cC = mySonyDevice.RenderingControl.ChannelState; OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Current_Volume", cV.ToString(), "Sony"); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Current_Channel", cC.ToString(), "Sony"); } else { this.Log.Info("The Sony device: " + mySonyDevice.Name + ", did not respond!"); this.Log.Info("Setting State for : " + mySonyDevice.Name + " to Offline."); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Online", "FALSE", "Sony"); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "OFF", "Sony"); if (debug) { this.Log.Debug("Make sure the Device is ON before running any Methods for " + mySonyDevice.Name); this.Log.Debug("If you continue to have issues, set the Registered Property to FALSE, and Re-DO the registration process again."); } mySonyReg = false; } } else { this.Log.Error("The Sony plugin did NOT find the object: " + objName); if (debug) { this.Log.Debug("The object " + objName + " Must be Powered ON!"); } } } catch (Exception ex) { this.Log.Error("The Check Status was unsuccessful."); if (debug) { this.Log.Debug("An error occurred while Checking the Status of the Device: " + ex.Message); } } return(mySonyReg); }
private void LoadNightSummaryLabels() { imgDay1Night.Tag = weatherObj.Property("Night1 Summary").Value; imgDay2Night.Tag = weatherObj.Property("Night2 Summary").Value; imgDay3Night.Tag = weatherObj.Property("Night3 Summary").Value; imgDay4Night.Tag = weatherObj.Property("Night4 Summary").Value; imgDay5Night.Tag = weatherObj.Property("Night5 Summary").Value; }
public override void ProcessCommand(OSAEMethod method) { //throw new NotImplementedException(); this.Log.Info("RECEIVED: " + method.ObjectName + " - " + method.MethodName); sMethod = method.MethodName; objName = method.ObjectName; if (sMethod == "DISCOVERY") { discoverDevices(); } else if (sMethod == "REGISTER") { registerDevice(method); } else if (sMethod == "RETRIEVE") { bool reg = registerCheck(method); if (reg == true) { retrieveDeviceCmd(method); } else { this.Log.Error("The Sony Retreive Method did NOT complete because the Sony Device is Offline!"); } } else if (sMethod == "SETCHANNEL") { bool reg = registerCheck(method); if (reg == true) { setchannel(method); } else { this.Log.Error("The Sony Set Channel Method did NOT complete because the Sony Device is Offline!"); } } else { bool reg = registerCheck(method); if (reg == true) { try { objName = method.ObjectName; sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.initialize(sonyobj.Name, sonyobj.Property("Host").Value, sonyobj.Property("Port").Value, sonyobj.Property("Mac").Value); string sCommand = method.MethodLabel; mySonyDevice.get_remote_command_list(); sCommand = mySonyDevice.getIRCCcommandString(sCommand); string results = mySonyDevice.send_ircc(sCommand); if (results == "") { this.Log.Error("The Method " + method.MethodName + " was not executed by " + mySonyDevice.Name); } else { this.Log.Info("Executed: " + mySonyDevice.Name + " - " + method.MethodLabel); this.Log.Debug(mySonyDevice.Name + " returned this information: " + results); } System.Threading.Thread.Sleep(500); } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); this.Log.Debug("The Sony Method" + method.MethodName + " did not execute!"); } } else { this.Log.Error("The Sony Method did NOT Execute because the Sony Device is Offline!"); } } }
public string renameingSys(string fieldData, string camParam1, string camParam2) { string renameProperty; string getProperty; string changeProperty = ""; newData = fieldData.Replace("http://", ""); try { while (newData.IndexOf("[") != -1) { int ss = newData.IndexOf("["); int es = newData.IndexOf("]"); renameProperty = newData.Substring(ss + 1, (es - ss) - 1); if (camParam1 != "") { if (camParam1 == renameProperty) { if (camParam2 == "") { Log.Debug("Property change Error: NO Parameter 2 for property " + camParam1); } else { int ssp = camParam2.IndexOf("["); int esp = camParam2.IndexOf("]"); if (ssp > -1 && esp > 0) { camParam2 = camParam2.Substring(ssp + 1, esp - 1); camParam2 = camobj.Property(camParam2).Value; } changeProperty = camParam2; Log.Debug("Property changed by Method Parameter 1: [" + renameProperty + "] to " + camParam2); } } else { changeProperty = camobj.Property(renameProperty).Value; } } else { changeProperty = camobj.Property(renameProperty).Value; } getProperty = changeProperty; // log any errors if (getProperty.Length > 0) { newData = newData.Replace("[" + renameProperty + "]", getProperty); } else { Log.Error("Property " + getProperty + " has NO data"); } if (getProperty == null) { Log.Error("Property " + getProperty + " NOT FOUND"); } } newData = @"http://" + newData; return(newData); } catch (Exception ex) { Log.Error("A renaming error occurred!!!", ex); return(null); } }
private void LoadControl(OSAEObject obj) { #region State Image if (obj.Type == "CONTROL STATE IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlStateImage ctrl = (ASP.ctrlStateImage)LoadControl("~/controls/ctrlStateImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); UpdatePlaceholder.Controls.Add(ctrl); //stateImages.Add(ctrl); } #endregion #region Click Image else if (obj.Type == "CONTROL CLICK IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlClickImage ctrl = (ASP.ctrlClickImage)LoadControl("~/controls/ctrlClickImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); StaticPlaceholder.Controls.Add(ctrl); } #endregion #region Navigation Image else if (obj.Type == "CONTROL NAVIGATION IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlNavigationImage ctrl = (ASP.ctrlNavigationImage)LoadControl("~/controls/ctrlNavigationImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); StaticPlaceholder.Controls.Add(ctrl); } #endregion #region Property Label else if (obj.Type == "CONTROL PROPERTY LABEL") { // Create instance of the UserControl SimpleControl ASP.ctrlPropertyLabel ctrl = (ASP.ctrlPropertyLabel)LoadControl("~/controls/ctrlPropertyLabel.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); UpdatePlaceholder.Controls.Add(ctrl); } #endregion #region Timer Label else if (obj.Type == "CONTROL TIMER LABEL") { // Create instance of the UserControl SimpleControl ASP.ctrlTimerLabel ctrl = (ASP.ctrlTimerLabel)LoadControl("~/controls/ctrlTimerLabel.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); UpdatePlaceholder.Controls.Add(ctrl); } #endregion #region Camera Viewer else if (obj.Type == "CONTROL CAMERA VIEWER") { // Create instance of the UserControl SimpleControl ASP.ctrlEmbedded ctrl = (ASP.ctrlEmbedded)LoadControl("~/controls/ctrlEmbedded.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); //ctrl.initialize(); ctrl.Source = OSAEObjectManager.GetObjectByName(ctrl.screenObject.Property("Object Name").Value).Property("Stream Address").Value; ctrl.width = "400"; ctrl.height = "300"; StaticPlaceholder.Controls.Add(ctrl); } #endregion #region User Control else if (obj.BaseType == "USER CONTROL") { string sUCType = obj.Property("Control Type").Value; string ucName = sUCType.Replace("USER CONTROL ", ""); // Create instance of the UserControl SimpleControl dynamic ctrl = LoadControl("~/controls/usercontrols/" + ucName + "/ctrlUserControl.ascx") as System.Web.UI.UserControl; // Set the Public Properties ctrl.screenObject = obj; ctrl.initialize(); UpdatePlaceholder.Controls.Add(ctrl); } #endregion #region Browser Control else if (obj.Type == "CONTROL BROWSER") { // Create instance of the UserControl SimpleControl ASP.ctrlBrowser ctrl = (ASP.ctrlBrowser)LoadControl("~/controls/ctrlBrowser.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); StaticPlaceholder.Controls.Add(ctrl); } #endregion }
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 = ""; } }
private bool IsMyStructureHome(OSAEObject myobject) { bool ishome; string mystructure = myobject.Property("Structure ID").Value; if (OSAEObjectManager.GetObjectByAddress(mystructure).State.Value.ToUpper().Equals("HOME")) ishome = true; else ishome = false; return ishome; }
private bool IsTempOK(string temptype,string temp,OSAEObject myobject) { bool tempisok = true; float mylowtemp = -1, myhightemp = 100; string tempscale; float.TryParse(myobject.Property("Target Temperature Low").Value, out mylowtemp); float.TryParse(myobject.Property("Target Temperature High").Value, out myhightemp); tempscale = myobject.Property("Temperature Scale").Value; if (tempscale.ToLower().Equals("f")) { int convertedtemp; if (Int32.TryParse(temp, out convertedtemp)) { if (convertedtemp < 50 || convertedtemp > 90) tempisok = false; if (temptype.Equals("high") && convertedtemp < mylowtemp) tempisok = false; if (temptype.Equals("low") && convertedtemp > myhightemp) tempisok = false; } else tempisok = false; } else { float convertedtemp; if (float.TryParse(temp, out convertedtemp)) { if (convertedtemp < 9 || convertedtemp > 32) tempisok = false; if (temptype.Equals("high") && convertedtemp < mylowtemp) tempisok = false; if (temptype.Equals("low") && convertedtemp > myhightemp) tempisok = false; } else tempisok = false; } return tempisok; }
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(); }
public override void ProcessCommand(OSAEMethod method) { //throw new NotImplementedException(); this.Log.Info("RECEIVED: " + method.ObjectName + " - " + method.MethodName); sMethod = method.MethodName; objName = method.ObjectName; if (sMethod == "DISCOVERY") { discoverDevices(); } else if (sMethod == "REGISTER") { registerDevice(method); } else if (sMethod == "RETRIEVE") { bool reg = registerCheck(method); if (reg == true) { retrieveDeviceCmd(method); } else { this.Log.Error("The Sony Retreive Method did NOT complete because the Sony Device is Offline!"); } } else if (sMethod == "SETCHANNEL") { bool reg = registerCheck(method); if (reg == true) { setchannel(method); } else { this.Log.Error("The Sony Set Channel Method did NOT complete because the Sony Device is Offline!"); } } else { bool reg = registerCheck(method); if (reg == true) { try { objName = method.ObjectName; sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.initialize(sonyobj.Name, sonyobj.Property("Host").Value, sonyobj.Property("Port").Value, sonyobj.Property("Mac").Value); string sCommand = method.MethodLabel; mySonyDevice.get_remote_command_list(); sCommand = mySonyDevice.getIRCCcommandString(sCommand); string results = mySonyDevice.send_ircc(sCommand); if (results == "") { this.Log.Error("The Method " + method.MethodName + " was not executed by " + mySonyDevice.Name ); } else { this.Log.Info("Executed: " + mySonyDevice.Name + " - " + method.MethodLabel); this.Log.Debug(mySonyDevice.Name + " returned this information: " + results); } System.Threading.Thread.Sleep(500); } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); this.Log.Debug("The Sony Method" + method.MethodName + " did not execute!"); } } else { this.Log.Error("The Sony Method did NOT Execute because the Sony Device is Offline!"); } } }
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; } }
public string renameingSys(string fieldData) { newData = fieldData.Replace("http://", ""); while (newData.IndexOf("[") != -1) { int ss = newData.IndexOf("["); int es = newData.IndexOf("]"); string renameProperty = newData.Substring(ss + 1, (es - ss) - 1); string getProperty = OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Property("Object Name").Value, renameProperty).Value; // log any errors if (getProperty.Length > 0) { newData = newData.Replace("[" + renameProperty + "]", getProperty); } else { this.Log.Error("Property has NO data"); } if (getProperty == null) { this.Log.Error("Property: NOT FOUND"); } } newData = @"http://" + newData; return(newData); }
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); }
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 void updateonline() { OSAEObjectCollection sonydevices = OSAEObjectManager.GetObjectsByOwner("Sony"); foreach (OSAEObject device in sonydevices) { string objName = device.Name; sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.initialize(sonyobj.Name, sonyobj.Property("Host").Value, sonyobj.Property("Port").Value, sonyobj.Property("Mac").Value); OSAEMethod updatereg = new OSAEMethod(); updatereg.ObjectName = mySonyDevice.Name; registerCheck(updatereg); } }
public TimerLabel(OSAEObject sObj) { InitializeComponent(); screenObject = sObj; ObjectName = screenObject.Property("Object Name").Value; OSAEObject timerObj = OSAEObjectManager.GetObjectByName(ObjectName); if (timerObj.Property("OFF TIMER").Value != "") OffTimer = Int32.Parse(timerObj.Property("OFF TIMER").Value); else OffTimer = 0; CurrentState = timerObj.State.Value; TimeInState = (int)timerObj.State.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 = "OFF"; 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 (Exception myerror) { } } if (sForeColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush; timerLabel.Foreground = brush; } catch (Exception myerror) { } } if (iFontSize != "") { try { timerLabel.FontSize = Convert.ToDouble(iFontSize); } catch (Exception myerror) { } } timerLabel.Content = sValue; } else { timerLabel.Content = ""; } timer.Interval = 1000; timer.Enabled = true; timer.Elapsed += new ElapsedEventHandler(timer_tick); }
public void setchannel(OSAEMethod method) { objName = method.ObjectName; sonyobj = OSAEObjectManager.GetObjectByName(objName); mySonyDevice.initialize(sonyobj.Name, sonyobj.Property("Host").Value, sonyobj.Property("Port").Value, sonyobj.Property("Mac").Value); mySonyDevice.get_remote_command_list(); string channel = method.Parameter1; try { mySonyDevice.channel_set(channel); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Current_Channel", channel, "Sony Plugin"); this.Log.Info("Executed: " + mySonyDevice.Name + " - Set Channel to: " + channel); } catch (Exception ex) { this.Log.Error("Set Channel Method: Error occurred!!!: " + ex.Message); } }
private void LoadNightSummaryLabels() { if (weatherObj.Property("Tonight Summary").Value != "") { imgTodayNight.ToolTip = weatherObj.Property("Tonight Summary").Value; } else { imgTodayNight.ToolTip = "Sorry, No Information Available!"; } if (weatherObj.Property("Night1 Summary").Value != "") { imgDay1Night.ToolTip = weatherObj.Property("Night1 Summary").Value; } else { imgDay1Night.ToolTip = "Sorry, No Information Available!"; } if (weatherObj.Property("Night2 Summary").Value != "") { imgDay2Night.ToolTip = weatherObj.Property("Night2 Summary").Value; } else { imgDay2Night.ToolTip = "Sorry, No Information Available!"; } if (weatherObj.Property("Night3 Summary").Value != "") { imgDay3Night.ToolTip = weatherObj.Property("Night3 Summary").Value; } else { imgDay3Night.ToolTip = "Sorry, No Information Available!"; } if (weatherObj.Property("Night4 Summary").Value != "") { imgDay4Night.ToolTip = weatherObj.Property("Night4 Summary").Value; } else { imgDay4Night.ToolTip = "Sorry, No Information Available!"; } if (weatherObj.Property("Night5 Summary").Value != "") { imgDay5Night.ToolTip = weatherObj.Property("Night5 Summary").Value; } else { imgDay5Night.ToolTip = "Sorry, No Information Available!"; } }
private string getPropertyValue(OSAEObject o, string p) { string s=""; if (OSAEObjectPropertyManager.ObjectPropertyExists(o.Name, p)) return o.Property(p).Value; else { switch (p) { case propModel: case propDeviceaddr: case propProtocol: case propTrustLevel: case propAddrComputerName: case propPort: case propLastCmd: case propLevel: logD("getPropertyValue", o.Name, "Property " + p + " does not exist, read ignored.", o); s = ""; break; case propMethods: logW("getPropertyValue", o.Name, "Property " + p + " does not exist, no Methods can be executed."); s = ""; break; case propDevChgEvent: case propAddDevices: case propAddSensors: case propSystemPlugin: logD("getPropertyValue", o.Name, "Property " + p + " does not exist, default to true.", o); s = "TRUE"; break; case propDebug: case propRawEvents: logD("getPropertyValue", o.Name, "Property " + p + " does not exist, default to false.", o); s = "FALSE"; break; case propAddrPrefix: logD("getPropertyValue", o.Name, "Property " + p + " does not exist, default to 'TellstickId-'.", o); s = "TellstickId-"; break; case propAddrPrefixSensor: logD("getPropertyValue", o.Name, "Property " + p + " does not exist, default to 'TellstickSensor-'.", o); s = "TellstickSensor-"; break; case propAvgSensors: logD("getPropertyValue", o.Name, "Property " + p + " does not exist, default to 10.", o); s = "10"; break; case propDevId: logW("getPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated."); OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, propDevId, "Integer", "", "", true); s=""; break; case sensDTTemp: logW("getPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated."); OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, propTemp, "Float", "", "0", true); s="0"; break; case sensDTHum: logW("getPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated."); OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, propHum, "Float", "", "0", true); s="0"; break; case propMinHum: case propMaxHum: case propMinTemp: case propMaxTemp: case propAvgHum: case propAvgTemp: logW("getPropertyValue", o.Name, "Property " + p + " does not exist, property will be recreated."); OSAEObjectTypeManager.ObjectTypePropertyAdd(o.Type, p, "Float", "", "0", true); s = "0"; break; } return s; } }
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; } }