Exemplo n.º 1
0
 // Invoke the ReceivedPacket event
 protected virtual void OnReceivedPacket(ManagerEventArgs e)
 {
     if (ReceivedPacket != null) { ReceivedPacket(this, e); }
 }
Exemplo n.º 2
0
 // Invoke the NewDevice event
 protected virtual void OnNewDevice(ManagerEventArgs e)
 {
     if (NewDevice != null) { NewDevice(this, e); }
 }
Exemplo n.º 3
0
 // Invoke the HypothesisChanged event
 protected virtual void OnHypothesisChanged(ManagerEventArgs e)
 {
     if (HypothesisChanged != null) { HypothesisChanged(this, e); }
 }
Exemplo n.º 4
0
        public void UpdateHypothesis(string name, bool value, string label = null)
        {
            //Console.WriteLine("HYPOTHESIS: " + name + "=" + value + " (" + label + ").");

            if (label == null) { label = name; }
            if (!value && activeHypothesis.ContainsKey(name))
            {
                activeHypothesis.Remove(name);
            }
            else if (value)
            {
                activeHypothesis[name] = label;
            }

            string currentLabel = null;
            foreach (KeyValuePair<string, string> kvp in activeHypothesis)
            {
                currentLabel = kvp.Value;
            }
            //Console.WriteLine("HYPOTHESIS: " + currentLabel);
            CurrentHypothesis = currentLabel;
            ManagerEventArgs mea = new ManagerEventArgs(name, value, label);
            OnHypothesisChanged(mea);

            if (outStompConnection == null && !outStompAttempted)
            {
                try
                {
                    outStompConnection = new StompConnection(outStompHost, outStompPort);
                }
                catch (Exception)
                {
                    ;
                }
                outStompAttempted = true;
            }
            if (outStompConnection != null)
            {
                // Create JSON-encoded data
                Hashtable sourceData = new Hashtable();
                sourceData.Add("name", name);
                sourceData.Add("value", value);
                string jsonData = Json.JsonEncode(sourceData);
                outStompConnection.Send(outStompTopic, jsonData);
                Console.WriteLine("Sent " + jsonData + " to " + outStompTopic);
            }
            else
            {
                //Console.WriteLine("FAILED to send to " + outStompTopic);
            }
        }
Exemplo n.º 5
0
 void waxManager_ReceivedPacket(object sender, ManagerEventArgs e)
 {
     if (autoInvalidate)
     {
         this.Invalidate();
     }
 }
Exemplo n.º 6
0
 void waxManager_NewDevice(object sender, ManagerEventArgs e)
 {
     this.Invalidate();
 }