private void EstablishStatusConnection(bool initialconnection) { try { if (statusStreamReader != null) { statusStreamReader.Close(); } if (statusStreamWriter != null) { statusStreamWriter.Close(); } if (statusTcpClient != null) { statusTcpClient.Close(); } } catch (Exception ex) { log("Error closing old status connections to MediaCenter device (" + _name + "): " + ex.Message, false); } try { if (_ip != "" && _StatusPort != 0) { if (initialconnection) { log("Creating Status TCP Client (" + _name + "): ip-" + _ip + " statusport-" + _StatusPort, false); } statusTcpClient = new TcpClient(_ip, _StatusPort); //get a network stream from server statusSockStream = statusTcpClient.GetStream(); // create new writer and reader stream to send and receive statusStreamWriter = new StreamWriter(statusSockStream); statusStreamReader = new StreamReader(statusSockStream); //Start listening Thread statuslistenThread = new Thread(new ThreadStart(statusListen)); statuslistenThread.Start(); OSAEObjectStateManager.ObjectStateSet(_name, "ON", pName); } else { if (initialconnection) { log(_name + " - Properties not set correctly: ip-" + _ip + " networkport-" + _CommandPort + " statusport-" + _StatusPort, true); } } } catch (Exception ex) { if (initialconnection) { log("Error creating connection to MediaCenter device (" + _name + "): " + ex.Message, true); } OSAEObjectStateManager.ObjectStateSet(_name, "OFF", pName); } }
public void registerDevice(OSAEMethod method) { try { objName = method.ObjectName; if (CheckObjByName(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)); if (mySonyDevice.Registered == false) { mySonyReg = mySonyDevice.Register(); if (mySonyReg == true) { OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Registered", "TRUE", "Sony"); 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.."); if (debug) { 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("If a Pin code was displayed, you need to run sendAuth(Pincode) next!"); this.Log.Debug("Registration returned: " + mySonyReg.ToString() + " for : " + mySonyDevice.Name); } } } if (mySonyDevice.Registered == true) { string response = mySonyDevice.CheckStatus(); if (response != "") { this.Log.Info("Setting State for : " + mySonyDevice.Name + " to Online."); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "ON", "Sony Plugin"); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "Online", "TRUE", "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 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); if (debug) { this.Log.Debug("The object " + objName + " was not found"); } } } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { ObjectName = screenObject.Property("Object Name").Value; hdnObjName.Value = ObjectName; CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value; OSAEObject curObj = OSAEObjectManager.GetObjectByName(ObjectName); hdnCurState.Value = CurState; LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange; tblWeather.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() + ";"); try { ControlWidth = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Width").Value); ControlHeight = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Height").Value); } catch (Exception ex) { } string sBackColor = screenObject.Property("Back Color").Value; string sForeColor = screenObject.Property("Fore Color").Value; int iFontSize = Convert.ToInt16(screenObject.Property("Font Size").Value) - 4; string sFontName = screenObject.Property("Font Name").Value; if (sBackColor != "") { try { tblWeather.BackColor = System.Drawing.Color.FromName(sBackColor); } catch (Exception) { } } if (sForeColor != "") { try { lblCurTemp.ForeColor = System.Drawing.Color.FromName(sForeColor); lblDay1.ForeColor = System.Drawing.Color.FromName(sForeColor); lblDay2.ForeColor = System.Drawing.Color.FromName(sForeColor); lblDay3.ForeColor = System.Drawing.Color.FromName(sForeColor); lblDay4.ForeColor = System.Drawing.Color.FromName(sForeColor); lblDay5.ForeColor = System.Drawing.Color.FromName(sForeColor); } catch (Exception) { } } if (iFontSize >= 0) { try { lblDay1.Font.Size = new FontUnit(iFontSize); lblDay2.Font.Size = new FontUnit(iFontSize); lblDay3.Font.Size = new FontUnit(iFontSize); lblDay4.Font.Size = new FontUnit(iFontSize); lblDay5.Font.Size = new FontUnit(iFontSize); } catch (Exception) { } } if (sFontName != "") { try { lblDay1.Font.Name = sFontName; lblDay2.Font.Name = sFontName; lblDay3.Font.Name = sFontName; lblDay4.Font.Name = sFontName; lblDay5.Font.Name = sFontName; } catch (Exception) { } } Load_All_Weather(); }
public void Update() { OSAEImageManager imgMgr = new OSAEImageManager(); bool stateChanged = false; try { OSAEObjectState stateCurrent = OSAEObjectStateManager.GetObjectStateValue(ObjectName); if (CurState != stateCurrent.Value) { stateChanged = true; } CurState = stateCurrent.Value; CurStateLabel = stateCurrent.StateLabel; LastStateChange = stateCurrent.LastStateChange; } catch { } foreach (OSAEObjectProperty p in screenObject.Properties) { if (p.Value.ToLower() == CurState.ToLower()) { StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } } try { Location.X = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " X").Value); Location.Y = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " Y").Value); try { string propertyCheck = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value; if (propertyCheck != "") { LightLevel = Convert.ToUInt16(propertyCheck); } else { LightLevel = 100; } } catch { } if (sliderVisible && updatingSlider == false) { try { CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value; } catch { CurLevel = "0"; } Dispatcher.Invoke((Action)(() => { sldSlider.ToolTip = CurLevel + "%"; sldSlider.Value = Convert.ToUInt16(CurLevel); if (CurLevel != "") { Image.ToolTip = ObjectName + "\n" + CurStateLabel + " (" + CurLevel + "%) since: " + LastStateChange; } else { Image.ToolTip = ObjectName + "\n" + CurStateLabel + " since: " + LastStateChange; } })); } if (stateChanged) { timer.Stop(); 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; if (imgName != "") { OSAEImage img1 = imgMgr.GetImage(imgName); if (img1 != null) { ms1 = new MemoryStream(img1.Data); imageFrames = 1; currentFrame = 1; Dispatcher.Invoke((Action)(() => { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); Image.Source = bitmapImage; ImageWidth = bitmapImage.Width; ImageHeight = bitmapImage.Height; })); // Primary Frame is loaded, load up additional frames for the time to display. if (imgName2 != "") { OSAEImage img2 = imgMgr.GetImage(imgName2); if (img2 != null) { ms2 = new MemoryStream(img2.Data); imageFrames = 2; if (imgName3 != "") { OSAEImage img3 = imgMgr.GetImage(imgName3); if (img3 != null) { ms3 = new MemoryStream(img3.Data); imageFrames = 3; if (imgName4 != "") { OSAEImage img4 = imgMgr.GetImage(imgName4); if (img4 != null) { ms4 = new MemoryStream(img4.Data); imageFrames = 4; } } } } } } } } else { Dispatcher.Invoke((Action)(() => { Image.Source = null; // Image.Visibility = System.Windows.Visibility.Hidden; })); } if (imageFrames > 1) { timer.Start(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "StateImage Update"); } }
// 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; DataSet ds = OSAEObjectStateManager.ObjectStateListGet(objName); if (ds.Tables[0].Rows.Count > 0) { State1Name = ds.Tables[0].Rows[0]["state_name"].ToString(); State1Label = ds.Tables[0].Rows[0]["state_label"].ToString(); } if (ds.Tables[0].Rows.Count > 1) { State2Name = ds.Tables[0].Rows[1]["state_name"].ToString(); State2Label = ds.Tables[0].Rows[1]["state_label"].ToString(); } CurState = OSAEObjectStateManager.GetObjectStateValue(objName).Value; LastStateChange = OSAEObjectStateManager.GetObjectStateValue(objName).LastStateChange; try { ControlWidth = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Width").Value); ControlHeight = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Height").Value); } catch (Exception ex) { } 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 (sBackColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush; btnState.Background = brush; } catch (Exception) { } } if (sForeColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush; btnState.Foreground = brush; } catch (Exception) { } } if (iFontSize != "") { try { btnState.FontSize = Convert.ToDouble(iFontSize); } catch (Exception) { } } if (sFontName != "") { try { btnState.FontFamily = new FontFamily(sFontName); } catch (Exception) { } } //propLabel.Content = sPrefix + sPropertyValue + sSuffix; Update_Button(); }
private void search() { try { Guid uuid = BluetoothService.L2CapProtocol; BluetoothDeviceInfo bdi; BluetoothAddress ba; byte tmp; bool found = false; int discarded; bc = new BluetoothClient(); bc.InquiryLength = new TimeSpan(0, 0, 0, int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Discover Length").Value), 0); nearosaeDevices = bc.DiscoverDevices(10, false, false, true); for (int j = 0; j < nearosaeDevices.Length; j++) { string addr = nearosaeDevices[j].DeviceAddress.ToString(); Object obj = OSAEObjectManager.GetObjectByAddress(addr); if (obj == null) { if (OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Learning Mode").Value == "TRUE") { OSAEObjectManager.ObjectAdd(nearosaeDevices[j].DeviceName, nearosaeDevices[j].DeviceName, "BLUETOOTH DEVICE", nearosaeDevices[j].DeviceAddress.ToString(), string.Empty, true); OSAEObjectPropertyManager.ObjectPropertySet(nearosaeDevices[j].DeviceName, "Discover Type", "0", gAppName); if (gDebug) { Log.Debug(addr + " - " + nearosaeDevices[j].DeviceName + ": added to OSA"); } } } } OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("BLUETOOTH DEVICE"); foreach (OSAEObject obj in objects) { found = false; string address = obj.Address; byte[] byteArray = HexEncoding.GetBytes(address, out discarded); tmp = byteArray[0]; byteArray[0] = byteArray[5]; byteArray[5] = tmp; tmp = byteArray[1]; byteArray[1] = byteArray[4]; byteArray[4] = tmp; tmp = byteArray[2]; byteArray[2] = byteArray[3]; byteArray[3] = tmp; ba = new BluetoothAddress(byteArray); bdi = new BluetoothDeviceInfo(ba); if (gDebug) { Log.Debug("Begin search for " + address); } for (int j = 0; j < nearosaeDevices.Length; j++) { if (nearosaeDevices[j].DeviceAddress.ToString() == address) { found = true; if (gDebug) { Log.Debug(address + " - " + obj.Name + ": found with DiscoverDevices"); } } } if (!found) { if (gDebug) { Log.Debug(address + " - " + obj.Name + ": failed with DiscoverDevices"); } } try { if (!found && (int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 2 || Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 0)) { if (gDebug) { Log.Debug(address + " - " + obj.Name + ": attempting GetServiceRecords"); } bdi.GetServiceRecords(uuid); found = true; if (gDebug) { Log.Debug(address + " - " + obj.Name + " found with GetServiceRecords"); } } } catch (Exception ex) { if (gDebug) { Log.Debug(address + " - " + obj.Name + " failed GetServiceRecords. exception: " + ex.Message); } } try { if (!found && (int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 3 || int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 0)) { if (gDebug) { Log.Debug(address + " - " + obj.Name + ": attempting Connection"); } //attempt a connect BluetoothEndPoint ep; ep = new BluetoothEndPoint(bdi.DeviceAddress, BluetoothService.Handsfree); //MessageBox.Show("attempt connect: " + pairedDevices[i].DeviceAddress); bc.Connect(ep); if (gDebug) { Log.Debug(address + " - " + obj.Name + " found with Connect attempt"); } bc.Close(); found = true; } } catch (Exception ex) { Log.Error(address + " - " + obj.Name + " failed with Connect attempt. exception: " + ex.Message); } if (found) { OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", gAppName); if (gDebug) { Log.Debug(obj.Name + " Status Updated in osae"); } } else { OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", gAppName); if (gDebug) { Log.Debug(obj.Name + " Status Updated in osae"); } } } } catch (Exception ex) { Log.Error("Error searching for devices", ex); } }
/// <summary> /// /// </summary> public void LoadPlugins(string serviceName) { Log = new General.OSAELog(serviceName); Log.Info("Loading Plugins..."); OSAEPluginCollection newPlugins = new OSAEPluginCollection(); var pluginAssemblies = new List <OSAEPluginBase>(); var types = PluginFinder.FindPlugins(); foreach (var type in types) { Log.Debug("TypeName: " + type.TypeName + ", AssemblyName: " + type.AssemblyName); var domain = Common.CreateSandboxDomain("Sandbox Domain", type.Location, SecurityZone.Internet, typeof(OSAEService)); domain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledPluginExceptions); Plugin p = new Plugin(type.AssemblyName, type.TypeName, domain, type.Location); if (!pluginLoaded(p.PluginType)) { newPlugins.Add(p); } } Log.Info("Found " + newPlugins.Count.ToString() + " Assemblies"); MySqlConnection connection = new MySqlConnection(Common.ConnectionString); foreach (Plugin plugin in newPlugins) { try { Log.Info("----------------------------------------------------"); if (plugin.PluginName != "") { OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName); if (obj == null) { bool found = OSAEObjectTypeManager.ObjectTypeExists(plugin.PluginType); if (found) { OSAEObjectManager.ObjectAdd(plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, "", serviceName, 50, false); Log.Info(obj.Name + ": Plugin Object Not found. Plugin Object Created."); obj = OSAEObjectManager.GetObjectByName(plugin.PluginName); if (obj == null) { Log.Info(obj.Name + ": I failed to create the Plugin Object!"); } } else { Log.Info(": Plugin Object Type Not found for: " + plugin.PluginType + ". Plugin Object Cannot be Created."); } } if (obj != null) { Log.Info(obj.Name + ": Plugin Object found. Plugin Object Enabled = " + obj.Enabled.ToString()); //No idea why the following line would run //OSAEObjectManager.ObjectUpdate(plugin.PluginName,plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, "", serviceName, 50, true); if (obj.Enabled == true) { plugin.Enabled = true; startPlugin(serviceObject, plugin); } else { plugin.Enabled = false; OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", serviceObject); } Log.Info(obj.Name + ": Plugin Enabled = " + plugin.Enabled.ToString()); Log.Info(obj.Name + ": Plugin Version = " + plugin.PluginVersion); OSAEObjectManager.ObjectUpdate(plugin.PluginName, plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, obj.Address, serviceName, 50, plugin.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Version", plugin.PluginVersion, serviceName); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Author", plugin.PluginAuthor, serviceName); } } else { bool found = OSAEObjectTypeManager.ObjectTypeExists(plugin.PluginType); if (found) { plugin.PluginName = plugin.PluginType; Log.Info(plugin.PluginName + ": Plugin object does not exist in DB!"); OSAEObjectManager.ObjectAdd(plugin.PluginName, "", plugin.PluginName, plugin.PluginType, "", "System", 50, false); OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Version", plugin.PluginVersion, serviceName); OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Author", plugin.PluginAuthor, serviceName); Log.Info(plugin.PluginName + ": Plugin added to DB."); //Uh, this still looks wrong below. I don't think it is needed, besides, any new plugin is disabled... //UDPConnection.SendObject("Plugin", plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051)); } else { Log.Info(": Plugin Object Type Not found for: " + plugin.PluginType + ". Plugin Object Cannot be Created!"); } } plugins.Add(plugin); masterPlugins.Add(plugin); } catch (Exception ex) { Log.Error("Error loading plugin: " + ex.Message, ex); } } OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject); }
void Player_OnStop(string sender = null, Player.OnStopdataType data = null) { logging.AddToLog(Name + " stopped playing", false); OSAEObjectStateManager.ObjectStateSet(Name, "Stopped", "XBMC"); }
void Player_OnPause(string sender = null, XBMCRPC.Player.Notifications.Data data = null) { logging.AddToLog(Name + " paused", false); OSAEObjectStateManager.ObjectStateSet(Name, "Stopped", "XBMC"); }
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; try { LightLevel = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value); } catch (Exception ex) { LightLevel = 100; } 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(); } }
void Player_OnPlay(string sender = null, XBMCRPC.Player.Notifications.Data data = null) { logging.AddToLog(Name + " started playing", false); OSAEObjectStateManager.ObjectStateSet(Name, "Playing", "XBMC"); }
public void Update() { try { CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value; CurStateLabel = OSAEObjectStateManager.GetObjectStateValue(ObjectName).StateLabel; LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange; } catch (Exception ex) { } foreach (OSAEObjectProperty p in screenObject.Properties) { if (p.Value.ToLower() == CurState.ToLower()) { StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } } try { //Location.X = Double.Parse(screenObject.Property(StateMatch + " X").Value); //Location.Y = Double.Parse(screenObject.Property(StateMatch + " Y").Value); timer.Stop(); Location.X = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " X").Value); Location.Y = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " Y").Value); try { LightLevel = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value); } catch (Exception ex) { LightLevel = 100; } string imgName = screenObject.Property(StateMatch + " Image").Value; img1 = imgMgr.GetImage(imgName); imgName = screenObject.Property(StateMatch + " Image 2").Value; img2 = imgMgr.GetImage(imgName); imgName = screenObject.Property(StateMatch + " Image 3").Value; img3 = imgMgr.GetImage(imgName); imgName = screenObject.Property(StateMatch + " Image 4").Value; img4 = imgMgr.GetImage(imgName); if (img1 != null) { var imageStream = new MemoryStream(img1.Data); imageFrames = 1; this.Dispatcher.Invoke((Action)(() => { var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = imageStream; bitmapImage.EndInit(); Image.Source = bitmapImage; if (sliderVisible && updatingSlider == false) { CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value; sldSlider.ToolTip = CurLevel + "%"; sldSlider.Value = Convert.ToUInt16(CurLevel); } if (CurLevel != "") { Image.ToolTip = ObjectName + "\n" + CurStateLabel + " (" + CurLevel + "%) since: " + LastStateChange; } else { Image.ToolTip = ObjectName + "\n" + CurStateLabel + " since: " + LastStateChange; } })); } if (img2 != null) { imageFrames = 2; } if (img3 != null) { imageFrames = 3; } if (img4 != null) { imageFrames = 4; } if (imageFrames > 1) { timer.Start(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "StateImage Update"); } }
private void PluginMessageReceived(PacketHeader header, Connection connection, string message) { string[] arguments = message.Split('|'); if (arguments[1] == "True") { OSAEObjectStateManager.ObjectStateSet(arguments[0], "ON", sourceName); } else if (arguments[1] == "False") { OSAEObjectStateManager.ObjectStateSet(arguments[0], "OFF", sourceName); } foreach (Plugin p in plugins) { if (p.PluginName == arguments[0]) { OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName); if (obj != null) { bool isSystemPlugin = false; foreach (OSAEObjectProperty p2 in obj.Properties) { if (p2.Name == "System Plugin") { if (p2.Value == "TRUE") { isSystemPlugin = true; } break; } } if (arguments[1] == "True" && !p.Enabled && !isSystemPlugin) { OSAEObjectManager.ObjectUpdate(p.PluginName, p.PluginName, obj.Description, obj.Type, obj.Address, obj.Container, 1); try { enablePlugin(p); this.Log.Debug("Activated plugin: " + p.PluginName); } catch (Exception ex) { this.Log.Error("Error activating plugin (" + p.PluginName + ")", ex); } } else if (arguments[1] == "False" && p.Enabled && !isSystemPlugin) { OSAEObjectManager.ObjectUpdate(p.PluginName, p.PluginName, obj.Description, obj.Type, obj.Address, obj.Container, 0); try { disablePlugin(p); this.Log.Debug("Deactivated plugin: " + p.PluginName); } catch (Exception ex) { this.Log.Error("Error stopping plugin (" + p.PluginName + ")", ex); } } } } } }
private void statusListen() { int cursessionindex = -1; int currsessionnum = -1; DateTime sessiontime = DateTime.Now; System.TimeSpan sessioninfoduration = new System.TimeSpan(0, 0, 0, 15); //session info occurs within 15 seconds otherwise we can't identify what session it belongs to System.TimeSpan sessionkeepduration = new System.TimeSpan(0, 1, 0, 0); //keep session for 1 hour after last update while (statusTcpClient.Connected) { try { string curLine = statusStreamReader.ReadLine(); if (!curLine.Equals("")) { if (curLine.IndexOf("TrackTime=") > -1) { int tracktime; bool isNum = Int32.TryParse(curLine.Replace("TrackTime=", ""), out tracktime); if (isNum) { if (tracktime % 30 == 0 || tracktime == 1) { log("Received status data from MCDevice(" + _name + "): " + curLine, false); } OSAEObjectPropertyManager.ObjectPropertySet(_name, "Current Position", curLine.Replace("TrackTime=", ""), pName); } else { log("Error parsing tracktime (" + _name + "): ", false); } } else { log("Received status data from MCDevice(" + _name + "): " + curLine, false); if (curLine.IndexOf("StartSession=") > -1 || curLine.IndexOf("204 Connected (") > -1) { int sessionnum; bool isNum = Int32.TryParse(curLine.Replace("StartSession=", ""), out sessionnum); if (isNum) { currsessionnum = sessionnum; } else { currsessionnum = 0; } Session currsession = new Session(sessionnum); sessiontime = DateTime.Now; sessions.Add(currsession); } if (curLine.IndexOf("EndSession=") > -1) { int sessionnum; bool isNum = Int32.TryParse(curLine.Replace("EndSession=", ""), out sessionnum); if (isNum) { int foundsession = findSession(sessionnum); if (foundsession != -1) { sessions[foundsession].active = false; } else // if we can't find that session then it could have been already in progress and got assigned session number 0 when we started.. so mark 0 and not active { foundsession = findSession(0); if (foundsession != -1) { sessions[foundsession].active = false; } } } } // session items if (DateTime.Now <= sessiontime.Add(sessioninfoduration)) { cursessionindex = findSession(currsessionnum); if (cursessionindex != -1) { if (curLine.IndexOf("Play=True") > -1) { sessions[cursessionindex].Play = true; } if (curLine.IndexOf("Stop=True") > -1) { sessions[cursessionindex].Stop = true; } //session types if (curLine.IndexOf("Recording=True") > -1) { sessions[cursessionindex].SessionType = "Recording"; } if (curLine.IndexOf("PVR=True") > -1) { sessions[cursessionindex].SessionType = "PVR"; } if (curLine.IndexOf("StreamingContentVideo=True") > -1) { sessions[cursessionindex].SessionType = "StreamingContentVideo"; } if (curLine.IndexOf("StreamingContentAudio=True") > -1) { sessions[cursessionindex].SessionType = "StreamingContentAudio"; } if (curLine.IndexOf("TVTuner=True") > -1) { sessions[cursessionindex].SessionType = "TVTuner"; } if (curLine.IndexOf("DVD=True") > -1) { sessions[cursessionindex].SessionType = "DVD"; } if (curLine.IndexOf("CD=True") > -1) { sessions[cursessionindex].SessionType = "CD"; } if (curLine.IndexOf("Radio=True") > -1) { sessions[cursessionindex].SessionType = "Radio"; } if (curLine.IndexOf("MediaName=") > -1) { sessions[cursessionindex].MediaName = curLine.Replace("MediaName=", ""); } if (curLine.IndexOf("MediaTime") > -1) { sessions[cursessionindex].MediaTimeS = curLine.Replace("MediaTime=", ""); } if (curLine.IndexOf("TrackNumber") > -1) { sessions[cursessionindex].TrackNumber = curLine.Replace("TrackNumber=", ""); } if (curLine.IndexOf("TrackDuration") > -1) { sessions[cursessionindex].MediaTimeS = curLine.Replace("TrackDuration=", ""); } } } else { // somehow we only need to update for non recording sessions (also if the curr session is a recording... find the last active non recording and update that) cursessionindex = findSession(currsessionnum); if (cursessionindex != -1) { if (curLine.IndexOf("MediaName=") > -1) { sessions[cursessionindex].MediaName = curLine.Replace("MediaName=", ""); } if (curLine.IndexOf("MediaTime") > -1) { sessions[cursessionindex].MediaTimeS = curLine.Replace("MediaTime=", ""); } if (curLine.IndexOf("TrackNumber") > -1) { sessions[cursessionindex].TrackNumber = curLine.Replace("TrackNumber=", ""); } if (curLine.IndexOf("TrackDuration") > -1) { sessions[cursessionindex].MediaTimeS = curLine.Replace("TrackDuration=", ""); } } } // Other Statuses (states, last screen, volume, last keypress, dialog visible, last dialog) if (curLine.IndexOf("Play=True") > -1) { OSAEObjectStateManager.ObjectStateSet(_name, "Playing", pName); } if (curLine.IndexOf("Stop=True") > -1) { OSAEObjectStateManager.ObjectStateSet(_name, "Stopped", pName); } if (curLine.IndexOf("Pause=True") > -1) { OSAEObjectStateManager.ObjectStateSet(_name, "Paused", pName); } if (curLine.IndexOf("Pause=True") > -1) { OSAEObjectStateManager.ObjectStateSet(_name, "Paused", pName); } if (curLine.IndexOf("Mute=True") > -1) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Mute", "TRUE", pName); } if (curLine.IndexOf("Mute=False") > -1) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Mute", "FALSE", pName); } if (curLine.IndexOf("Volume=") > -1) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Volume", curLine.Replace("Volume=", ""), pName); } if (curLine.IndexOf("FS_") > -1) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Last Screen", curLine.Replace("=True", "").Replace("FS_", ""), pName); } if (curLine.IndexOf("KeyPress=") > -1) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Last Key Press", curLine.Replace("KeyPress=", ""), pName); } if (curLine.IndexOf("DialogVisible=True") > -1) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Dialog Visible", "TRUE", pName); } if (curLine.IndexOf("DialogVisible=False") > -1) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Dialog Visible", "FALSE", pName); } // now set recording info, media info, media type based on active sessions // also clean up sessions and time out any that appear to have been left open and orphaned Boolean Recording = false; String RecordingName = ""; String RecordingChannel = ""; int RecordingCount = 0; String MediaName = ""; String MediaTime = "0"; String MediaType = ""; cursessionindex = -1; foreach (Session s in sessions) { cursessionindex++; log("looping sessions for " + _name + " (" + sessions.Count().ToString() + ")- active:" + s.active + ", sessionnum:" + s.SessionNumber + ", type:" + s.SessionType + ", lastupdate:" + s.lastupdate + ", medianame:" + s.MediaName + ", play:" + s.Play.ToString() + ", stop:" + s.Stop.ToString(), false); if (s.active) { if (s.SessionType.Equals("Recording")) { Recording = true; RecordingChannel = RecordingChannel + s.TrackNumber + ", "; if (s.SessionNumber == 0) // fix issue when plugin first started it will give us the last media played and not the current recording name on start of the status connection { MediaName = s.MediaName; } else { RecordingName = RecordingName + s.MediaName + ", "; } RecordingCount++; } else { MediaName = s.MediaName; MediaTime = s.MediaTimeS; MediaType = s.SessionType; } } else { if (DateTime.Now >= s.lastupdate.Add(sessionkeepduration) && cursessionindex != sessions.Count() - 1) // if it is not active and hasn't been updated in an hour and is not the last session then remove it { sessions.Remove(s); } } } if (Recording) { RecordingName = RecordingName.TrimEnd(',', ' '); RecordingChannel = RecordingChannel.TrimEnd(',', ' '); OSAEObjectPropertyManager.ObjectPropertySet(_name, "Recording", "TRUE", pName); OSAEObjectPropertyManager.ObjectPropertySet(_name, "Recording Name", RecordingName, pName); OSAEObjectPropertyManager.ObjectPropertySet(_name, "Recording Channel", RecordingChannel, pName); OSAEObjectPropertyManager.ObjectPropertySet(_name, "Number of Recordings", RecordingCount.ToString(), pName); } else { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Recording", "FALSE", pName); OSAEObjectPropertyManager.ObjectPropertySet(_name, "Recording Name", "", pName); OSAEObjectPropertyManager.ObjectPropertySet(_name, "Recording Channel", "", pName); OSAEObjectPropertyManager.ObjectPropertySet(_name, "Number of Recordings", "0", pName); } if (!MediaName.Equals("")) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Media Name", MediaName, pName); } if (!MediaTime.Equals("0")) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Media Time", MediaTime, pName); } if (!MediaType.Equals("")) { OSAEObjectPropertyManager.ObjectPropertySet(_name, "Media Type", MediaType, pName); } } } else { log("Current line is blank - curLine>" + curLine + "<", false); } } catch (Exception ex) { log("Error reading from status stream (" + _name + "): " + ex.Message, true); } } }
private void Window_Closing(object sender, CancelEventArgs e) { OSAEObjectStateManager.ObjectStateSet(gAppName, "OFF", OSAE.Common.ComputerName); gAppClosing = true; }
public Boolean SetState(string objName, string state) { OSAEObjectStateManager.ObjectStateSet(objName, state, sourceName); return(true); }
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) { } } if (sFontName != "") { try { propLabel.FontFamily = new FontFamily(sFontName); } catch (Exception) { } } propLabel.Content = sPrefix + sPropertyValue + sSuffix; } else { propLabel.Content = ""; } }
public static string MatchPattern(string str) { string ScriptParameter = ""; try { DataSet dataset = new DataSet(); //command.CommandText = "SELECT pattern FROM osae_v_pattern WHERE `match`=@Name"; //command.Parameters.AddWithValue("@Name", str); dataset = OSAESql.RunSQL("SELECT pattern FROM osae_v_pattern WHERE `match`='" + str + "'"); if (dataset.Tables[0].Rows.Count > 0) { //Since we have a match, lets execute the scripts OSAEScriptManager.RunPatternScript(dataset.Tables[0].Rows[0]["pattern"].ToString(), "", "Jabber"); return(dataset.Tables[0].Rows[0]["pattern"].ToString()); } else { //Replace Words with place holders and retry the pattern match //example "Please turn the main light on" becomes "Please turn the [OBJECT] [STATE]" //Step 1: Break the Input into an Array to Query the Words for DB matches str = str.ToUpper(); string[] words = str.Split(' '); DataSet dsObjects = new DataSet(); foreach (String word in words) { dsObjects = OSAE.Common.ObjectNamesStartingWith(word); foreach (DataRow dr in dsObjects.Tables[0].Rows) { if (str.IndexOf(dr["object_name"].ToString()) > -1) //return "Found " + dr["object_name"].ToString(); { str = str.Replace(dr["object_name"].ToString(), "[OBJECT]"); ScriptParameter += dr["object_name"].ToString(); //Here We have found our Object, so we need to look for an appropriate state afterwards //So we are going to retrieve a state list and compare it to the remainder of the string DataSet dsStates = new DataSet(); dsStates = OSAEObjectStateManager.ObjectStateListGet(dr["object_name"].ToString()); foreach (DataRow drState in dsStates.Tables[0].Rows) { if (str.IndexOf(drState["state_label"].ToString().ToUpper()) > 0) { str = str.Replace(drState["state_label"].ToString().ToUpper(), "[STATE]"); ScriptParameter += ", " + drState["state_label"].ToString(); //Now that we have replaced the Object and State, Lets check for a match again //DataSet dataset = new DataSet(); //command.CommandText = "SELECT pattern FROM osae_v_pattern WHERE `match`=@Name"; //command.Parameters.AddWithValue("@Name", str); //dataset = OSAESql.RunQuery(command); dataset = OSAESql.RunSQL("SELECT pattern FROM osae_v_pattern WHERE `match`='" + str + "'"); if (dataset.Tables[0].Rows.Count > 0) { //return dataset.Tables[0].Rows[0]["pattern"].ToString(); //Since we have a match, lets execute the scripts OSAEScriptManager.RunPatternScript(dataset.Tables[0].Rows[0]["pattern"].ToString(), ScriptParameter, "Jabber"); return(dataset.Tables[0].Rows[0]["pattern"].ToString()); } break; } } break; } } } return(string.Empty); //return string.Empty; } } catch (Exception ex) { Logging.GetLogger().AddToLog("API - MatchPattern error: " + ex.Message, true); return(string.Empty); } }
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); }
protected void ddlState_SelectedIndexChanged(object sender, EventArgs e) { OSAEObjectStateManager.ObjectStateSet(hdnSelectedObjectName.Text, ddlState.SelectedItem.Value, "Web UI"); lblAlert.Text = "State set successfully to " + ddlState.SelectedItem.Text; alert.Visible = true; }
public override void ProcessCommand(OSAEMethod method) { //Process incomming command this.Log.Debug("Process command: " + method.MethodName); this.Log.Debug("Process parameter1: " + method.Parameter1); this.Log.Debug("Process parameter2: " + method.Parameter2); this.Log.Debug("Address: " + method.Address); switch (method.MethodName) { case "PLAY": if (method.Parameter1.Trim() == string.Empty) { sbs.Play(method.Address); } else { sbs.PlaylistPlay(method.Address, method.Parameter1); } OSAEObjectStateManager.ObjectStateSet(OSAEObjectManager.GetObjectByAddress(method.Address).Name, "PLAYING", pName); break; case "STOP": sbs.StopPlayer(method.Address); OSAEObjectStateManager.ObjectStateSet(OSAEObjectManager.GetObjectByAddress(method.Address).Name, "STOPPED", pName); break; case "NEXT": sbs.Next(method.Address); break; case "PREV": sbs.Previous(method.Address); break; case "SHOW": sbs.ShowMessage(method.Address, method.Parameter1, Int32.Parse(method.Parameter2)); break; case "PAUSE": sbs.PausePlayer(method.Address); OSAEObjectStateManager.ObjectStateSet(OSAEObjectManager.GetObjectByAddress(method.Address).Name, "PAUSED", pName); break; case "TTS": TextToSpeech(method.Parameter1); sbs.PlaylistPlay(method.Address, ttsPlay); break; case "TTSLIST": DataSet list = OSAEObjectPropertyManager.ObjectPropertyArrayGetAll(method.Parameter1, method.Parameter2); string tts = ""; int count = 1; foreach (DataRow item in list.Tables[0].Rows) { tts += " RSS item number " + count.ToString() + ". " + item["item_name"].ToString(); count++; } TextToSpeech(tts); sbs.PlaylistPlay(method.Address, ttsPlay); break; case "TTSLISTRAND": string listItem = OSAEObjectPropertyManager.ObjectPropertyArrayGetRandom(method.Parameter1, method.Parameter2); TextToSpeech(listItem); sbs.PlaylistPlay(method.Address, ttsPlay); break; } }
/// <summary> /// Event happens when a wcf client invokes it /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void wcfService_MessageReceived(object source, WCF.CustomEventArgs e) { try { logging.AddToLog("received message: " + e.Message.Type + " - " + e.Message.Message, false); if (e.Message.Type == WCF.OSAEWCFMessageType.CONNECT) { try { logging.AddToLog("client connected", false); foreach (Plugin p in masterPlugins) { string msg = p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | " + p.Status + " | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName; sendMessageToClients(WCF.OSAEWCFMessageType.PLUGIN, msg); } } catch (Exception ex) { logging.AddToLog("Error sending plugin messages to clients: " + ex.Message, true); } } else if (e.Message.Type == WCF.OSAEWCFMessageType.LOADPLUGINS) { LoadPlugins(); } else { string[] arguments = e.Message.Message.Split('|'); if (arguments[0] == "ENABLEPLUGIN") { bool local = false; if (arguments[2] == "True") { OSAEObjectStateManager.ObjectStateSet(arguments[1], "ON", sourceName); } else if (arguments[2] == "False") { OSAEObjectStateManager.ObjectStateSet(arguments[1], "OFF", sourceName); } foreach (Plugin p in plugins) { if (p.PluginName == arguments[1]) { local = true; OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName); if (obj != null) { if (arguments[2] == "True") { enablePlugin(p); } else if (arguments[2] == "False") { disablePlugin(p); sendMessageToClients(WCF.OSAEWCFMessageType.PLUGIN, p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Stopped | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName); } } } } if (!local) { sendMessageToClients(WCF.OSAEWCFMessageType.PLUGIN, e.Message.Message); } } else if (arguments[0] == "plugin") { bool found = false; foreach (Plugin plugin in masterPlugins) { if (plugin.PluginName == arguments[1]) { if (arguments[4].ToLower() == "true") { plugin.Enabled = true; } else { plugin.Enabled = false; } plugin.PluginVersion = arguments[3]; found = true; break; } } if (!found) { Plugin p = new Plugin(); p.PluginName = arguments[1]; p.PluginVersion = arguments[3]; if (arguments[4].ToLower() == "true") { p.Enabled = true; } else { p.Enabled = false; } masterPlugins.Add(p); } } else if (arguments[0] == "updatePlugin") { foreach (Plugin plugin in masterPlugins) { if (plugin.PluginType == arguments[1]) { if (plugin.Status == "ON") { disablePlugin(plugin); sendMessageToClients(WCF.OSAEWCFMessageType.PLUGIN, plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName); } //code for downloading and installing plugin break; } } } } logging.AddToLog("-----------Master plugin list", false); foreach (Plugin p in masterPlugins) { logging.AddToLog(" --- " + p.PluginName, false); } } catch (Exception ex) { logging.AddToLog("Error receiving message: " + ex.Message, true); } }
public StateImage(OSAEObject sObject, string appName) { InitializeComponent(); OSAEImageManager imgMgr = new OSAEImageManager(); gAppName = appName; screenObject = sObject; ObjectName = screenObject.Property("Object Name").Value; // ObjectType = 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 != 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) { Log.Debug("Found Command: " + method.MethodName + " | param1: " + method.Parameter1 + " | param2: " + method.Parameter2); if (method.ObjectName == pName) { if (method.MethodName == "SCAN") { _UDPSend.Send(); } } else { Receiver r = getReceiver(method.ObjectName); if (r != null) { #region Network if (r.Type == "Network") { switch (method.MethodName) { case "ON": SendCommand_Network(r, "!1PWR01"); OSAEObjectStateManager.ObjectStateSet(r.Name, "ON", pName); break; case "OFF": SendCommand_Network(r, "!1PWR00"); OSAEObjectStateManager.ObjectStateSet(r.Name, "OFF", pName); break; case "MUTE": SendCommand_Network(r, "!1AMT01"); break; case "UNMUTE": SendCommand_Network(r, "!1AMT00"); break; case "VOLUME UP": SendCommand_Network(r, "!1MVLUP"); break; case "VOLUME DOWN": SendCommand_Network(r, "!1MVLDOWN"); break; case "SET VOLUME": SendCommand_Network(r, "!1MVL" + Int32.Parse(method.Parameter1).ToString("X")); break; case "VCR/DVR": SendCommand_Network(r, "!1SLI00"); break; case "CBL/SAT": SendCommand_Network(r, "!1SLI01"); break; case "GAME": SendCommand_Network(r, "!1SLI02"); break; case "AUX1": SendCommand_Network(r, "!1SLI03"); break; case "BD/DVD": SendCommand_Network(r, "!1SLI10"); break; case "TV/CD": SendCommand_Network(r, "!1SLI23"); break; case "TUNER": SendCommand_Network(r, "!1SLI26"); break; case "DLNA": SendCommand_Network(r, "!1SLI2B"); SendCommand_Network(r, "!1NSV00"); break; case "VTUNER": SendCommand_Network(r, "!1SLI2B"); SendCommand_Network(r, "!1NSV02"); break; case "PANDORA": SendCommand_Network(r, "!1SLI2B"); SendCommand_Network(r, "!1NSV04"); break; case "SIRIUS": SendCommand_Network(r, "!1SLI2B"); SendCommand_Network(r, "!1NSV03"); break; case "MEDIAFLY": SendCommand_Network(r, "!1SLI2B"); SendCommand_Network(r, "!1NSV09"); break; case "NAPSTER": SendCommand_Network(r, "!1SLI2B"); SendCommand_Network(r, "!1NSV07"); break; case "FAVORITES": SendCommand_Network(r, "!1SLI2B"); SendCommand_Network(r, "!1NSV01"); break; case "UP": SendCommand_Network(r, "!1OSDUP"); break; case "DOWN": SendCommand_Network(r, "!1OSDDOWN"); break; case "RIGHT": SendCommand_Network(r, "!1OSDRIGHT"); break; case "LEFT": SendCommand_Network(r, "!1OSDLEFT"); break; case "ENTER": SendCommand_Network(r, "!1OSDENTER"); break; case "NETUP": SendCommand_Network(r, "!1NTCUP"); break; case "NETDOWN": SendCommand_Network(r, "!1NTCDOWN"); break; case "NETRIGHT": SendCommand_Network(r, "!1NTCRIGHT"); break; case "NETLEFT": SendCommand_Network(r, "!1NTCLEFT"); break; case "NETENTER": SendCommand_Network(r, "!1NTCSELECT"); break; } } #endregion else if (r.Type == "Serial") { } } } }
public void discoverDevices() { this.Log.Info(objName + " is performing Device Discovery..."); List <string> fDev = mySonyLib.Locator.LocateDevices(); if (fDev.Count > 0) { this.Log.Info("Discovery found: " + fDev.Count + " Device(s)"); for (int i = 0; i < fDev.Count; i++) { string selDev = fDev[i]; try { this.Log.Info("Building Object from Document: " + selDev); mySonyDevice.BuildFromDocument(new Uri(selDev)); } catch (Exception e) { this.Log.Error("ERROR - Building Object for " + mySonyDevice.Name, e); return; } this.Log.Info("Checking if Object " + mySonyDevice.Name + " is SONY Compatiable"); if (mySonyDevice.Ircc.ControlUrl != null) { if (!CheckObjByName(mySonyDevice.Name.ToString())) { try { this.Log.Info("Creating Sony Object Type for: " + mySonyDevice.Name); OSAEObjectTypeManager.ObjectTypeAdd(mySonyDevice.Name, "Sony Device", "Sony", mySonyDevice.Name, true, false, false, true); OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "REGISTER", "Register", "", "", "", "", "Executing this Method will Register this device wity OSA"); OSAEObjectTypeManager.ObjectTypeStateAdd(mySonyDevice.Name, "ON", "Online", "This state represents that the Sony Device is Online"); OSAEObjectTypeManager.ObjectTypeStateAdd(mySonyDevice.Name, "OFF", "OffLine", "This state represents that the Sony Device is Offline"); OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "DocumentURL", "String", "String", "", false, true, "Enter the URL to the Sony Device Document"); OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Current_Channel", "String", "String", "", false, false, "This will contain the current channel"); OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Current_Volume", "String", "String", "", false, false, "This will contain the current Volume Level"); OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Current_Status", "String", "String", "", false, false, "This will contain the current Device Status"); OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Registered", "Boolean", "String", "FALSE", false, true, "Select True/False if this device is registered"); OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Online", "Boolean", "String", "FALSE", false, true, "Select True/False if this device is Online"); this.Log.Info("Sony Object Type was Created: " + mySonyDevice.Name); this.Log.Info("Creating Object for " + mySonyDevice.Name); OSAEObjectManager.ObjectAdd(mySonyDevice.Name, "Sony Device", "Sony Device", mySonyDevice.Name, mySonyDevice.IPAddress, "", 30, true); OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "OFF", "Sony"); OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "DocumentURL", mySonyDevice.DocumentUrl, "Sony"); OSAEObjectManager.ObjectUpdate(mySonyDevice.Name, mySonyDevice.Name, "Sony Device", "Sony Device", mySonyDevice.Name, mySonyDevice.IPAddress, "", 30, true); this.Log.Info("Sony Object Created: " + mySonyDevice.Name); foreach (APILibrary.SonyCommands sCmd in mySonyDevice.Commands) { string cName = sCmd.name;; string cValue = sCmd.value; OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, cName.ToUpper(), cName, "", "", "", "", "Retrieved Method from Device"); this.Log.Info("Created Method: " + cName + " for device " + mySonyDevice.Name); if (cName == "ChannelUp") { OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "SETCHANNEL", "Set Channel", "Channel #", "", "", "", "Executing this method will set the entered channel on the device"); this.Log.Info("Created Method: Set Channel for device " + mySonyDevice.Name); } } OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "GETSTATUS", "Get Status", "", "", "", "", "Executing this method will retrieve the current status from the Sony Device"); this.Log.Info("Created Method: Get Status for device " + mySonyDevice.Name); OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "SENDTEXT", "Send Text", "Text", "", "", "", "Executing this method will send the netered text to the Sony Device"); this.Log.Info("Created Method: Send Text for device " + mySonyDevice.Name); OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "GETTEXT", "Get Text", "", "", "", "", "Executing this method will check if the Sony device is accepting a Text input"); this.Log.Info("Created Method: Get Text for device " + mySonyDevice.Name); if (debug) { this.Log.Debug("Run the Register method for the : " + mySonyDevice.Name + " Object to register this device!"); } } catch (Exception ex) { this.Log.Error("An error occurred!!!: " + ex.Message); if (debug) { this.Log.Debug("An Error occured in the Object Creation for: " + mySonyDevice.Name); } } } else { this.Log.Error("The object " + mySonyDevice.Name + " already exist. Object NOT Created"); } } else { this.Log.Debug("The object " + mySonyDevice.Name + " is NOT compatiable"); } } } else { this.Log.Error("The Sony Discovery Method did NOT find any devices"); } }
protected void Page_Load(object sender, EventArgs e) { ObjectName = screenObject.Property("Object Name").Value; hdnObjName.Value = ObjectName; CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value; OSAEObject curObj = OSAEObjectManager.GetObjectByName(ObjectName); hdnCurState.Value = CurState; LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange; btnState.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() + ";"); DataSet ds = OSAEObjectStateManager.ObjectStateListGet(ObjectName); if (ds.Tables[0].Rows.Count > 0) { State1Name = ds.Tables[0].Rows[0]["state_name"].ToString(); State1Label = ds.Tables[0].Rows[0]["state_label"].ToString(); } if (ds.Tables[0].Rows.Count > 1) { State2Name = ds.Tables[0].Rows[1]["state_name"].ToString(); State2Label = ds.Tables[0].Rows[1]["state_label"].ToString(); } CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value; LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange; try { ControlWidth = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Width").Value); ControlHeight = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Height").Value); } catch (Exception ex) { } btnState.Height = ControlHeight; btnState.Width = ControlWidth; // (ObjectName.Length + 4) * 8; string sBackColor = screenObject.Property("Back Color").Value; string sForeColor = screenObject.Property("Fore Color").Value; int iFontSize = Convert.ToInt16(screenObject.Property("Font Size").Value) - 3; string sFontName = screenObject.Property("Font Name").Value; if (sBackColor != "") { try { btnState.BackColor = System.Drawing.Color.FromName(sBackColor); } catch (Exception) { } } if (sForeColor != "") { try { btnState.ForeColor = System.Drawing.Color.FromName(sForeColor); } catch (Exception) { } } if (iFontSize != 0) { try { btnState.Font.Size = new FontUnit(iFontSize); } catch (Exception) { } } if (sFontName != "") { try { btnState.Font.Name = sFontName; } catch (Exception) { } } if (CurState == State1Name) { btnState.Text = ObjectName + " " + State1Label; btnState.ToolTip = "Click to Set " + ObjectName + " to " + State2Label; } else { btnState.Text = ObjectName + " " + State2Label; btnState.ToolTip = "Click to Set " + ObjectName + " to " + State1Label; } }
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); }
public void loadData(string objectName) { hvac_mode = OSAEObjectStateManager.GetObjectStateValue(objectName).Value.ToLower(); device_id = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Id").Value; name = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Name").Value; name_long = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Name Long").Value; temperature_scale = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Temperature Scale").Value; locale = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Locale").Value; software_version = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Software Version").Value; structure_id = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Structure ID").Value; fan_timer_timeout = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Fan Timer Timeout").Value; //convert _lastConnection to standard format for comparison DateTime _lastConnection; last_connection = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Last Connection").Value; if (!DateTime.TryParse(last_connection, out _lastConnection)) { last_connection = ""; } else { last_connection = _lastConnection.ToString("G"); // 1/29/2015 8:43:16 PM } Boolean _has_leaf; Boolean _is_online; Boolean _can_cool; Boolean _can_heat; Boolean _has_fan; Boolean _is_using_emergency_heat; Boolean _fan_timer_active; Boolean.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Has Leaf").Value, out _has_leaf); has_leaf = _has_leaf; Boolean.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Is Online").Value, out _is_online); is_online = _is_online; Boolean.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Can Cool").Value, out _can_cool); can_cool = _can_cool; Boolean.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Can Heat").Value, out _can_heat); can_heat = _can_heat; Boolean.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Has Fan").Value, out _has_fan); has_fan = _has_fan; Boolean.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Using Emergency Heat").Value, out _is_using_emergency_heat); is_using_emergency_heat = _is_using_emergency_heat; Boolean.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Fan Timer Active").Value, out _fan_timer_active); fan_timer_active = _fan_timer_active; float _ambient_temperature; float _humidity; float _target_temperature; float _target_temperature_high; float _target_temperature_low; float _away_temperature_high; float _away_temperature_low; float.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Humidity").Value, out _humidity); humidity = _humidity; float.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Ambient Temperature").Value, out _ambient_temperature); ambient_temperature_f = _ambient_temperature; ambient_temperature_c = _ambient_temperature; float.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Target Temperature").Value, out _target_temperature); target_temperature_f = _target_temperature; target_temperature_c = _target_temperature; float.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Target Temperature High").Value, out _target_temperature_high); target_temperature_high_f = _target_temperature_high; target_temperature_high_c = _target_temperature_high; float.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Target Temperature Low").Value, out _target_temperature_low); target_temperature_low_f = _target_temperature_low; target_temperature_low_c = _target_temperature_low; float.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Away Temperature High").Value, out _away_temperature_high); away_temperature_high_f = _away_temperature_high; away_temperature_high_c = _away_temperature_high; float.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Away Temperature Low").Value, out _away_temperature_low); away_temperature_low_f = _away_temperature_low; away_temperature_low_c = _away_temperature_low; }
protected void Page_Load(object sender, EventArgs e) { 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).StateLabel; sPropertyValue += " (" + TimeSpan.FromSeconds(OSAEObjectStateManager.GetObjectStateValue(ObjectName).TimeInState) + ")"; } 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; PropertyLabel.Text = sPrefix + sPropertyValue + sSuffix; PropertyLabel.Attributes.Add("Style", "position:absolute;top:" + (Int32.Parse(screenObject.Property("Y").Value) + 60).ToString() + "px;left:" + (Int32.Parse(screenObject.Property("X").Value) + 10).ToString() + "px;z-index:" + (Int32.Parse(screenObject.Property("ZOrder").Value) + 10).ToString() + ";"); if (sFontName != "") { try { PropertyLabel.Font.Name = sFontName; } catch (Exception) { } } if (sBackColor != "") { try { PropertyLabel.BackColor = Color.FromName(sBackColor); } catch (Exception) { } } if (sForeColor != "") { try { PropertyLabel.ForeColor = Color.FromName(sForeColor); } catch (Exception) { } } if (iFontSize != "") { try { PropertyLabel.Font.Size = new FontUnit(iFontSize); } catch (Exception) { } } }
public Boolean SetObjectState(string name, string state) { OSAEObjectStateManager.ObjectStateSet(name, state, "Rest"); Log.Debug("Setting object state: " + name + " set to: " + state + "."); return(true); }