private void checkSecurityKey() { try { Log.Info("Checking if System Security Key exist"); string cSSK = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue("System", "SecurityKey").Value; if (cSSK == " " || cSSK == "" || cSSK.Length < 16) { Log.Info("System Security Key found, but is not valid."); Log.Info("Generating a new Security Key..."); OSAEObjectPropertyManager.ObjectPropertySet("System", "SecurityKey", OSAESecurity.GenerateSecurityKey(), "Rest"); } else { Log.Info("System Security Key found."); } } catch { Log.Info("System Security Key does not exist.."); Log.Info("Creating System object property: SecurityKey."); OSAEObjectTypeManager.ObjectTypePropertyAdd("System", "SecurityKey", "String", "", "", false, true, "This key is used in HTTP and Rest authorization. Must be 16 characters."); Log.Info("Generating a new Security Key..."); OSAEObjectPropertyManager.ObjectPropertySet("System", "SecurityKey", OSAESecurity.GenerateSecurityKey(), "Rest"); } }
private void btnUpdate_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtScreenName.Text)) { MessageBox.Show("Please specify a name for the screen"); return; } if (img == null) { MessageBox.Show("Please specify an image for the screen"); return; } string tempName = "Screen - " + txtScreenName.Text.Replace("Screen - ", ""); OSAE.OSAEObject obj = OSAEObjectManager.GetObjectByName(sOriginalName); //We call an object update here in case the Name was changed, then perform the updates against the New name OSAEObjectManager.ObjectUpdate(sOriginalName, tempName, obj.Alias, obj.Description, obj.Type, obj.Address, obj.Container, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(tempName, "Background Image", img.Name, "GUI"); //OnLoadScreen(); NotifyParentFinished(); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("Please specify a name for the control"); return; } if (img == null) { MessageBox.Show("Please specify an image for the control"); return; } if (string.IsNullOrEmpty(screenComboBox.Text)) { MessageBox.Show("Please specify a target for the control"); return; } string sName = "Screen - Nav - " + txtName.Text; OSAEObjectManager.ObjectAdd(sName, sName, "CONTROL NAVIGATION IMAGE", "", currentScreen, true); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Image", img.Name, "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Screen", screenComboBox.Text, "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(sName, "X", "100", "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Y", "100", "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Zorder", "1", "GUI"); OSAEScreenControlManager.ScreenObjectAdd(currentScreen, screenComboBox.Text, sName); NotifyParentFinished(); }
public override void ProcessCommand(OSAEMethod method) { Log.Debug("Received command: " + method.MethodName); if (method.MethodName == "TWEET") { SendTweet(Common.PatternParse(method.Parameter1)); } else if (method.MethodName == "AUTHENTICATE") { string pin = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Pin").Value; if (pin != "") { Log.Info("Found pin: " + pin + ". Attempting to authorize"); try { // Now that the application's been authenticated, let's get the (permanent) // token and secret token that we'll use to authenticate from now on. _oAuth.AccessTokenGet(_oAuth.OAuthToken, pin.Trim()); OSAEObjectPropertyManager.ObjectPropertySet(pName, "Token", _oAuth.Token, pName); OSAEObjectPropertyManager.ObjectPropertySet(pName, "Token Secret", _oAuth.TokenSecret, pName); OSAEObjectPropertyManager.ObjectPropertySet(pName, "Auth Token", _oAuth.OAuthToken, pName); this.Log.Info("Success! You're ready to start tweeting!"); } catch (Exception ex) { Log.Error("An error occurred during authorization", ex); } } else { Log.Info("No pin found. Please enter the pin from twitter into the Twitter object property."); } } }
private void imgTodayDay_MouseUp(object sender, MouseButtonEventArgs e) { try { // ControlWidth = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Width").Value); // ControlHeight = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Height").Value); maxDays = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Max Days").Value); } catch (Exception ex) { } if (sMode == "Max") { sMode = "Min"; this.Width = sizes[0]; // bool minimized = Convert.ToBoolean( screenObject.Property("Minimized").Value); OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Minimized", "TRUE", gAppName); OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Width", sizes[0].ToString(), gAppName); ControlWidth = sizes[0]; } else { sMode = "Max"; this.Width = sizes[maxDays]; OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Minimized", "FALSE", gAppName); OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Width", sizes[maxDays].ToString(), gAppName); ControlWidth = sizes[maxDays]; // grdControl.Width = sizes[maxDays]; } }
public void updateconditions() { string feedUrl; string sXml; WebClient webClient = new WebClient(); XmlDocument xml; Log.Debug("*** Reading Conditions ***"); try { feedUrl = "http://api.wunderground.com/api/" + pKey + "/conditions/q/" + pState + "/" + pCity + ".xml"; if (gDebug) { Log.Debug("Reading Feed: " + feedUrl); } sXml = webClient.DownloadString(feedUrl); xml = new XmlDocument(); xml.LoadXml(sXml); //update all the weather variables #region Current Observation GetFieldFromXmlAndReport(xml, "Wind Speed", "response/current_observation/wind_mph"); GetFieldFromXmlAndReport(xml, "Wind Directions", "response/current_observation/wind_dir"); GetFieldFromXmlAndReport(xml, "Humidity", "response/current_observation/relative_humidity"); GetFieldFromXmlAndReport(xml, "Image", "response/current_observation/image/url"); GetFieldFromXmlAndReport(xml, "Last Updated", "response/current_observation/observation_time"); if (!Metric) { GetFieldFromXmlAndReport(xml, "Temp", "response/current_observation/temp_f"); GetFieldFromXmlAndReport(xml, "Pressure", "response/current_observation/pressure_in"); GetFieldFromXmlAndReport(xml, "Dewpoint", "response/current_observation/dewpoint_f"); GetFieldFromXmlAndReport(xml, "Windchill", "response/current_observation/windchill_f"); } else { GetFieldFromXmlAndReport(xml, "Temp", "response/current_observation/temp_c"); GetFieldFromXmlAndReport(xml, "Pressure", "response/current_observation/pressure_mb"); GetFieldFromXmlAndReport(xml, "Dewpoint", "response/current_observation/dewpoint_c"); GetFieldFromXmlAndReport(xml, "Windchill", "response/current_observation/windchill_c"); } // Only returned for airports. GetFieldFromXmlAndReport(xml, "Visibility", "response/current_observation/visibility_mi"); GetFieldFromXmlAndReport(xml, "Conditions", "response/current_observation/weather"); if (FirstUpdateRun) { latitude = GetNodeValue(xml, "response/current_observation/observation_location/latitude"); longitude = GetNodeValue(xml, "response/current_observation/observation_location/longitude"); OSAEObjectPropertyManager.ObjectPropertySet(WeatherObjName, "latitude", latitude, pName); OSAEObjectPropertyManager.ObjectPropertySet(WeatherObjName, "longitude", longitude, pName); } #endregion } catch (Exception ex) { Log.Error("Error updating current weather - ", ex); } FirstUpdateRun = false; }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { try { // ignore empty messages (events) if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error) { return; } oldMmsg = msg; DataSet dsResults = new DataSet(); //Build a List of all Users to identify who is sending the message. dsResults = OSAESql.RunSQL("SELECT DISTINCT(object_name) FROM osae_v_object_property WHERE property_name = 'JabberID' and property_value = '" + msg.From.Bare + "' ORDER BY object_name"); gCurrentUser = dsResults.Tables[0].Rows[0][0].ToString(); OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gCurrentUser); gCurrentAddress = msg.From.Bare; RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body); if (rr == null) { if (gDebug) { Log.Debug("INPUT: No Matching Pattern found!"); } } } catch (Exception ex) { Log.Error("Error in _OnMessage!", ex); } }
UInt32 pollInterval = 250; // 4x a second #endregion private void AddIO(string address, Direction dir, string serial, byte id) { if (OSAEObjectManager.GetObjectByAddress(address) == null) { if (dir == Direction.Input) { OSAEObjectManager.ObjectAdd("J-Works-I" + address, "", "J -Works input", "JWORKS INPUT", address, "", 30, true); } else { OSAEObjectManager.ObjectAdd("J-Works-0" + address, "", "J-Works output", "JWORKS OUTPUT", address, "", 30, true); } OSAEObjectPropertyManager.ObjectPropertySet(address, "Serial", serial, pName); OSAEObjectPropertyManager.ObjectPropertySet(address, "Id", Convert.ToString(id), pName); OSAEObjectPropertyManager.ObjectPropertySet(address, "Invert", "FALSE", pName); } OSAEObject obj = OSAEObjectManager.GetObjectByAddress(address); bool invert = (OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Invert").Value == "TRUE"); // initial state is 0; interpret that in light of Invert setting OSAEObjectStateManager.ObjectStateSet(obj.Name, invert ? "ON" : "OFF", pName); }
void xmppCon_OnPresence(object sender, agsXMPP.protocol.client.Presence pres) { string[] jIDRaw = pres.From.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects != null) { foreach (OSAEObject oObj in objects) { Log.Info(String.Format("Received Presence from: {0} show: {1} status: {2}", oObj.Name, pres.Show.ToString(), pres.Status)); if (pres.Show.ToString() == "away") { OSAEObjectPropertyManager.ObjectPropertySet(oObj.Name, "JabberStatus", "Idle", "Jabber"); } else if (pres.Show.ToString() == "NONE") { OSAEObjectPropertyManager.ObjectPropertySet(oObj.Name, "JabberStatus", "Online", "Jabber"); } break; } } else { Log.Info(String.Format("No object found with address of: {0}", jID, pres.Show.ToString(), pres.Status)); } }
void xmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item) { string[] jIDRaw = item.Jid.Bare.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects == null) { bool dupName = OSAEObjectManager.ObjectExists(item.Name); if (dupName) { Log.Info(String.Format("Found Object {0} for {1}", item.Name, jID)); } else { Log.Info(String.Format("Creating new Object {0} for {1}", item.Name, jID)); OSAEObjectManager.ObjectAdd(item.Name, "", "Discovered Jabber contact", "PERSON", "", "Unknown", 10, false); } Log.Info(String.Format("Updating JabberID for {0}", item.Name)); OSAEObjectPropertyManager.ObjectPropertySet(item.Name, "JabberID", jID, gAppName); } else { Log.Info(String.Format("Found Object {0} for {1}", item.Name, jID)); } }
private void checkAPIKey() { try { Log.Info("Checking if REST API Key exist"); string cRAK = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue("Rest", "APIKEY").Value; if (cRAK == " " || cRAK == "" || cRAK.Length < 32) { Log.Info("REST API Key found, but is not valid."); Log.Info("Creating a new REST API Key..."); OSAEObjectPropertyManager.ObjectPropertySet("Rest", "APIKEY", OSAESecurity.GenerateAPIKey(), "Rest"); } else { Log.Info("REST API Key found."); } } catch { Log.Info("REST API Key does not exist.."); Log.Info("Creating Rest Plugin property: APIKEY."); OSAEObjectTypeManager.ObjectTypePropertyAdd("Rest", "APIKEY", "String", "", "", false, true, "This is the Rest Plugin API Key. This property is used by remote clients and devices to encrypt and decrypt user information for authentication."); Log.Info("Generating a new REST API Key..."); OSAEObjectPropertyManager.ObjectPropertySet("Rest", "APIKEY", OSAESecurity.GenerateAPIKey(), "Rest"); } }
private void addButton_Click(object sender, RoutedEventArgs e) { if (ValidateForm("Add")) { string sName = cntrlName.Text; OSAEObjectManager.ObjectAdd(sName, sName, sName, osaeControlType + " " + _pluginName, "", currentScreen, 30, true); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Control Type", osaeControlType + " " + _pluginName, currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Object Name", objectsComboBox.Text, currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "X", "100", currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Y", "100", currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "ZOrder", "1", currentUser); if (hasParams == true) { foreach (objParams op in oParams) { OSAEObjectPropertyManager.ObjectPropertySet(sName, op.Name, op.Value, currentUser); } } OSAEScreenControlManager.ScreenObjectAdd(currentScreen, objectsComboBox.Text, sName); NotifyParentFinished(); } // else // { // Do not save until feilds are correct // } }
private void btnUpdate_Click(object sender, RoutedEventArgs e) { if (ValidateForm("Update")) { sWorkingName = cntrlName.Text; OSAE.OSAEObject obj = OSAEObjectManager.GetObjectByName(sOriginalName); //We call an object update here in case the Name was changed, then perform the updates against the New name OSAEObjectManager.ObjectUpdate(sOriginalName, sWorkingName, obj.Alias, obj.Description, obj.Type, obj.Address, obj.Container, obj.MinTrustLevel, obj.Enabled); string sName = cntrlName.Text; OSAEObjectManager.ObjectUpdate(sOriginalName, sName, "", sName, osaeControlType + " " + _pluginName, "", currentScreen, 30, true); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Control Type", osaeControlType + " " + _pluginName, currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Object Name", objectsComboBox.Text, currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "X", cntrlX.Text, currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "Y", cntrlY.Text, currentUser); OSAEObjectPropertyManager.ObjectPropertySet(sName, "ZOrder", cntrlZOrder.Text, currentUser); if (hasParams == true) { foreach (objParams op in oParams) { OSAEObjectPropertyManager.ObjectPropertySet(sName, op.Name, op.Value, currentUser); } } OSAEScreenControlManager.ScreenObjectUpdate(currentScreen, objectsComboBox.Text, sName); NotifyParentFinished(); } // else // { // Do not save until feilds are correct // } }
private void ReportFieldValue(string fieldName, string fieldValue) { if (fieldValue.Length > 0) { OSAEObjectPropertyManager.ObjectPropertySet(WeatherObjName, fieldName, fieldValue, pName); if (fieldName == "Temp") { if (gDebug) { Log.Debug("...Found " + fieldName + ": " + fieldValue); } else if (gDebug) { Log.Debug("...Found " + fieldName + ": " + fieldValue); } } } else { if (fieldName != "Windchill" & fieldName != "Visibility" & fieldName != "Conditions") { if (gDebug) { Log.Debug("NOT FOUND " + fieldName); } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Load_App_Name(); OSAE.OSAEObject tempAlias = OSAE.OSAEObjectManager.GetObjectByName(gSystemName); if (tempAlias.Alias.Length > 0) { gSystemName = tempAlias.Alias; } try { oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized); oRecognizer.AudioStateChanged += new EventHandler <AudioStateChangedEventArgs>(oRecognizer_StateChanged); } catch (Exception ex) { AddToLog("Unable to configure oRecognizer"); AddToLog("Error: " + ex.Message); } Load_Settings(); Common.CheckComputerObject(gAppName); oRecognizer = OSAEGrammar.Load_User_Grammar(oRecognizer); try { gSpeechPlugin = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Can Hear this Plugin").Value.ToString(); if (gSpeechPlugin == "") { gSpeechPlugin = "Speech"; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Can Hear this Plugin", "Speech", "VR Client"); } AddToLog("-- I will ignore speech from: " + gSpeechPlugin); oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); oRecognizer = OSAEGrammar.Load_Voice_Grammars(oRecognizer); SaveGrammars(); AddToLog("Finished Loading..."); AddToLog("_______________________________________________"); AddToLog("Who are you?"); Thread t1 = new Thread(delegate() { oRecognizer.SetInputToDefaultAudioDevice(); oRecognizer.RecognizeAsync(RecognizeMode.Multiple); while (!gAppClosing) { Thread.Sleep(333); } }); t1.Start(); } catch (Exception ex) { AddToLog("Unable to set Default Audio Device. Check Sound Card."); AddToLog("Error: " + ex.Message); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Load_App_Name(); try { oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized); oRecognizer.AudioStateChanged += new EventHandler <AudioStateChangedEventArgs>(oRecognizer_StateChanged); AudioState state = oRecognizer.AudioState; // This shows AudioState.Stopped } catch (Exception ex) { AddToLog("Unable to configure oRecognizer"); AddToLog("Error: " + ex.Message); } Load_Settings(); Load_Grammer(); Load_Grammer_With_Substitutions(); try { oRecognizer.SetInputToDefaultAudioDevice(); AddToLog("Recognizer Settings: "); AddToLog("-- Level: " + oRecognizer.AudioLevel.ToString()); AddToLog("-- End Silence Timeout: " + oRecognizer.EndSilenceTimeout); AddToLog("-- Recognition Babble Timeout: " + oRecognizer.BabbleTimeout); AddToLog("Audio Format Settings: "); AddToLog("-- EncodingFormat: " + oRecognizer.AudioFormat.EncodingFormat); AddToLog("-- Channel Count: " + oRecognizer.AudioFormat.ChannelCount); AddToLog("-- Bits Per Sample: " + oRecognizer.AudioFormat.BitsPerSample); AddToLog("-- Samples Per Second: " + oRecognizer.AudioFormat.SamplesPerSecond); AddToLog("-- Average Bytes Per Second: " + oRecognizer.AudioFormat.AverageBytesPerSecond); gSpeechPlugin = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Can Hear this Plugin").Value.ToString(); if (gSpeechPlugin == "") { gSpeechPlugin = "Speech"; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Can Hear this Plugin", "Speech", "VR Client"); } AddToLog("-- I will ignore speech from: " + gSpeechPlugin); Thread t1 = new Thread(delegate() { oRecognizer.SetInputToDefaultAudioDevice(); oRecognizer.RecognizeAsync(); while (!gAppClosing) { Thread.Sleep(333); } }); t1.Start(); //oRecognizer.RecognizeAsync(); AddToLog("Finished Loading, Recognition Started..."); } catch (Exception ex) { AddToLog("Unable to set Default Audio Device. Check Sound Card."); AddToLog("Error: " + ex.Message); } }
private void Load_Settings() { try { try { gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value); } catch { Log.Error("I think the Debug property is missing from the Speech object type!"); } Log.Info("Debug Mode Set to " + gDebug); gSelectedVoice = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Voice").Value; OSAEObjectPropertyManager.ObjectPropertyArrayDeleteAll(gAppName, "Voices"); foreach (System.Speech.Synthesis.InstalledVoice i in oSpeech.GetInstalledVoices()) { if (gSelectedVoice == "") { gSelectedVoice = i.VoiceInfo.Name; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Voice", gSelectedVoice, "SPEECH"); Log.Info("Default Voice Set to " + gSelectedVoice); } Log.Info("Adding Voice: " + i.VoiceInfo.Name); OSAEObjectPropertyManager.ObjectPropertyArrayAdd(gAppName, "Voices", i.VoiceInfo.Name, "Voice"); } if (gSelectedVoice != "") { oSpeech.SelectVoice(gSelectedVoice); Log.Info("Current Voice Set to " + gSelectedVoice); } // Load the speech rate, which must be -10 to 10, and set it to 0 if it is not valid. Int16 iTTSRate = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Rate").Value); if (iTTSRate < -10 || iTTSRate > 10) { iTTSRate = 0; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "TTS Rate", iTTSRate.ToString(), gAppName); Log.Info("TTS Rate was invalid! I changed it to " + iTTSRate.ToString()); } Log.Info("TTS Rate Set to " + iTTSRate.ToString()); oSpeech.Rate = iTTSRate; Int16 iTTSVolume = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Volume").Value); if (iTTSVolume < -10 || iTTSVolume > 10) { iTTSVolume = 0; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "TTS Volume", iTTSVolume.ToString(), gAppName); Log.Info("TTS Volume was invalid! I changed it to " + iTTSVolume.ToString()); } oSpeech.Rate = iTTSVolume; Log.Info("TTS Volume Set to " + iTTSVolume.ToString()); } catch (Exception ex) { Log.Error("Error in Load_Settings!", ex); } }
private void updateObjectCoordsStateImg(OSAE.OSAEObject obj, string state, string X, string Y) { OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, state + " X", X, "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, state + " Y", Y, "GUI"); obj.Property(state + " X").Value = X; obj.Property(state + " Y").Value = Y; }
protected override void ProcessRecord() { logging.AddToLog("Set-OSA - ProcessRecord - Started", false); OSAEObject obj = OSAEObjectManager.GetObjectByName(Name); OSAEObjectPropertyManager.ObjectPropertySet(Name, Property, Value, source); WriteObject(true); }
/// <summary> /// The service control manager has requested us to start /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { Log.Debug("OnStart subroutine Starting..."); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptions); var dbConnectionStatus = Common.TestConnection(); if (dbConnectionStatus.Success) { Log.Info("Verified successful connection to database."); } else { Log.Fatal("Unable to connect to database: " + dbConnectionStatus.CaughtException.Message); return; } try { string externalip = new System.Net.WebClient().DownloadString("https://api.ipify.org"); OSAEObjectPropertyManager.ObjectPropertySet("SYSTEM", "WAN IP", externalip, "SERVICE"); } catch (Exception ex) { Log.Fatal("Error getting registry settings and/or deleting logs: " + ex.Message, ex); } try { Common.InitialiseLogFolder(); DeleteStoreFiles(); } catch (Exception ex) { Log.Fatal("Error getting registry settings and/or deleting logs: " + ex.Message, ex); } Log.Info("Removing Orphaned Methods"); OSAEMethodManager.ClearMethodQueue(); try { OSAE.OSAESql.RunSQL("SET GLOBAL event_scheduler = ON;"); } catch (Exception ex) { Log.Fatal("Error setting the event scheduler: " + ex.Message, ex); } checkLog = new System.Timers.Timer(60000); checkLog.Elapsed += checkLogEvent; checkLog.Enabled = true; // Start the network service so messages can be // received by the service StartNetworkListener(); // Start the threads that monitor the plugin // updates check the method queue and so on StartThreads(serviceObject); }
protected override void ProcessRecord() { this.Log.Debug("Set-OSA - ProcessRecord - Started"); OSAEObject obj = OSAEObjectManager.GetObjectByName(Name); OSAEObjectPropertyManager.ObjectPropertySet(Name, Property, Value, source); WriteObject(true); }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { try { // ignore empty messages (events) if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error) { return; } oldMmsg = msg; string[] jIDRaw = msg.From.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects != null) { foreach (OSAEObject oObj in objects) { if (oObj.Alias.Length > 0) { gCurrentUser = oObj.Alias; } else { gCurrentUser = oObj.Name; } } } else { Log.Info("Message from Unknown address: " + jID); } if (gDebug) { Log.Debug("Current User set to: " + gCurrentUser); } OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gAppName); gCurrentAddress = jID; if (msg.Body.EndsWith("?") || msg.Body.EndsWith("!") || msg.Body.EndsWith(".")) { msg.Body = msg.Body.Substring(0, msg.Body.Length - 1); } RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body); if (rr == null) { if (gDebug) { Log.Debug("INPUT: No Matching Pattern found!"); } } } catch (Exception ex) { Log.Error("Error in _OnMessage!", ex); } }
private void Set_Default_Screen() { OSAEObjectCollection screens = OSAEObjectManager.GetObjectsByType("SCREEN"); if (screens.Count > 0) { gCurrentScreen = screens[0].Name; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Default Screen", gCurrentScreen, "GUI"); } }
public override void RunInterface(string pluginName) { gAppName = pluginName; Log = new General.OSAELog(gAppName); OwnTypes(); Load_Settings(); OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Speaking", "TRUE", gAppName); oSpeech.Speak("speech client started"); OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Speaking", "FALSE", gAppName); }
public void Load_Screen(string sScreen) { try { while (updatingScreen) { System.Threading.Thread.Sleep(100); } loadingScreen = true; //this.Log.Debug("Loading screen: " + sScreen); stateImages.Clear(); propLabels.Clear(); navImages.Clear(); clickImages.Clear(); cameraViewers.Clear(); canGUI.Children.Clear(); browserFrames.Clear(); gCurrentScreen = sScreen; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Current Screen", sScreen, "GUI"); OSAE.OSAEImageManager imgMgr = new OSAE.OSAEImageManager(); string imgID = OSAEObjectPropertyManager.GetObjectPropertyValue(sScreen, "Background Image").Value; OSAE.OSAEImage img = imgMgr.GetImage(imgID); //sPath = OSAEApi.APIpath + OSAEApi.GetObjectPropertyValue(sScreen, "Background Image").Value; //byte[] byteArray = File.ReadAllBytes(sPath); if (img.Data != null) { var imageStream = new MemoryStream(img.Data); var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = imageStream; bitmapImage.EndInit(); canGUI.Background = new ImageBrush(bitmapImage); canGUI.Height = bitmapImage.Height; canGUI.Width = bitmapImage.Width; } //Thread threadLoad = new Thread(() => Load_Objects(sScreen)); //threadLoad.Start(); Load_Objects(sScreen); loadingScreen = false; //this.Log.Debug("Loading screen complete: " + sScreen); } catch (Exception ex) { this.Log.Error("Failed to load screen: " + sScreen, ex); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (validateForm("Add")) { string tempName = txtScreenName.Text; OSAEObjectManager.ObjectAdd(tempName, "", tempName, "SCREEN", "", tempName, 50, true); OSAEObjectPropertyManager.ObjectPropertySet(tempName, "Background Image", img.Name, currentUser); currentScreen = txtScreenName.Text; OSAEObjectManager.ObjectAdd(tempName + " - User Selector", "", tempName + " - User Selector", "CONTROL USER SELECTOR", "", tempName, 50, true); NotifyParentFinished(); } }
private void btnUpdate_Click(object sender, RoutedEventArgs e) { if (validateForm("Update")) { string tempName = txtScreenName.Text; OSAE.OSAEObject obj = OSAEObjectManager.GetObjectByName(sOriginalName); //We call an object update here in case the Name was changed, then perform the updates against the New name OSAEObjectManager.ObjectUpdate(sOriginalName, tempName, obj.Alias, obj.Description, obj.Type, obj.Address, obj.Container, obj.MinTrustLevel, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(tempName, "Background Image", img.Name, currentUser); NotifyParentFinished(); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { OSAEObjectManager.ObjectAdd(txtName.Text, txtName.Text, "CONTROL BROWSER", "", currentScreen, true); OSAEObjectPropertyManager.ObjectPropertySet(txtName.Text, "URI", txtURI.Text, "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(txtName.Text, "Width", txtWidth.Text, "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(txtName.Text, "Height", txtHeight.Text, "GUI"); OSAEObjectPropertyManager.ObjectPropertySet(txtName.Text, "ZOrder", "1", "GUI"); OSAEScreenControlManager.ScreenObjectAdd(currentScreen, "", txtName.Text); NotifyParentFinished(); }
private void PollDevices() { OSAEObjectCollection devices = OSAEObjectManager.GetObjectsByType("Radio Thermostat Device"); foreach (OSAEObject obj in devices) { ThermostatLib.ThermostatInfo status = ThermostatLib.ThermostatInfo.Load(obj.Address); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Current Temperature", status.Temperature.ToString(), pName); Log.Debug("Current Temperature: " + status.Temperature.ToString()); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Thermostat State", status.ThermostatState, pName); Log.Debug("Thermostat State: " + status.ThermostatState); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Fan State", status.FanState, pName); Log.Debug("Fan State: " + status.FanState); if (status.TemporaryCool > 0) { OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Set Temperature", status.TemporaryCool.ToString(), pName); Log.Debug("Set Temperature: " + status.TemporaryCool.ToString()); } else { OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Set Temperature", status.TemporaryHeat.ToString(), pName); Log.Debug("Set Temperature: " + status.TemporaryHeat.ToString()); } OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Thermostat Mode", status.ThermostatMode, pName); Log.Debug("Thermostat Mode: " + status.ThermostatMode); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Fan Mode", status.FanMode, pName); Log.Debug("Fan Mode: " + status.FanMode); if (status.Hold) { OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Hold", "Yes", pName); } else { OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Hold", "No", pName); } if (status.Override) { OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Override", "Yes", pName); } else { OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Override", "No", pName); } } }
public void Question_Answered(string answer) { oRecognizer.UnloadAllGrammars(); oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); oRecognizer = OSAEGrammar.Load_OSA_Grammar(oRecognizer); sendMessage(Common.PatternParse("Setting " + gAnswerObject + "'s " + gAnswerProperty + " to " + answer), gCurrentAddress); Log.Info(Common.PatternParse("Setting " + gAnswerObject + "'s " + gAnswerProperty + " to " + answer)); OSAEObjectPropertyManager.ObjectPropertySet(gAnswerObject, gAnswerProperty, answer, gCurrentUser); //Trust is enforced in the storedProc, but maybe it can be checked here for better replies. gAnswerObject = ""; gAnswerProperty = ""; }