/// <summary>
        /// Call this method to insert a Event
        /// </summary>
        /// <param name="source"></param>
        /// <param name="isremote"></param>
        public void EventRecieved(UAVSingleParameter source, bool isremote)
        {
            if (source.updateRate == Int32.MaxValue) return;
            if (source.updateRate == 0){
                if (forwarded != null) forwarded(source, false);
                return;
            }
            lock (Syncobj)
            {

            if (list.ContainsKey(source.GetStringPath()))
            {
             //   timespans[source.Name] = DateTime.Now;
             /*   if (source.Value is double)
                {
                     list[source.Name].Value = Convert.ToDouble(source.Value.ToString());
                }else
                {
              * */
                    var toupdate =list[source.GetStringPath()];
                    toupdate.Value = (UAVSingleParameter)source;
                    toupdate.Timestamp = DateTime.Now;

              //  }

            }
            else {
                    list.Add(source.GetStringPath(), new EventValue(DateTime.Now,source));

              //  list.Add(source.GetStringPath(), (UAVParameter)source);//.Clone()
               // timespans.TryAdd(source.GetStringPath(), DateTime.Now);
            }

            }
        }
Beispiel #2
0
        /// <summary>
        /// Call this method to insert a Event
        /// </summary>
        /// <param name="source"></param>
        /// <param name="isremote"></param>
        public void EventRecieved(UAVSingleParameter source, bool isremote)
        {
            if (source.updateRate == Int32.MaxValue)
            {
                return;
            }
            if (source.updateRate == 0)
            {
                if (forwarded != null)
                {
                    forwarded(source, false);
                }
                return;
            }
            lock (Syncobj)
            {
                if (list.ContainsKey(source.GetStringPath()))
                {
                    //   timespans[source.Name] = DateTime.Now;

                    /*   if (source.Value is double)
                     * {
                     *      list[source.Name].Value = Convert.ToDouble(source.Value.ToString());
                     * }else
                     * {
                     * */
                    var toupdate = list[source.GetStringPath()];
                    toupdate.Value     = (UAVSingleParameter)source;
                    toupdate.Timestamp = DateTime.Now;

                    //  }
                }
                else
                {
                    list.Add(source.GetStringPath(), new EventValue(DateTime.Now, source));

                    //  list.Add(source.GetStringPath(), (UAVParameter)source);//.Clone()
                    // timespans.TryAdd(source.GetStringPath(), DateTime.Now);
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Sends a UAVParameter to all clients
 /// </summary>
 /// <param name="param"></param>
 public void Send(UAVSingleParameter param)
 {
     foreach (TcpClient myclient in clients)
     {
         if (myclient.Connected)
         {
             if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US")
             {
                 System.Threading.Thread.CurrentThread.CurrentCulture = new
                                                                        System.Globalization.CultureInfo("en-US");
             }
             NetworkStream clientStream = myclient.GetStream();
             UTF8Encoding  encoder      = new UTF8Encoding();
             byte[]        buffer       = encoder.GetBytes(param.GetStringPath() + "|" + DateTime.UtcNow.Ticks.ToString() + "|" + param.Value.ToString() + "\n");
             clientStream.Write(buffer, 0, buffer.Length);
             clientStream.Flush();
         }
     }
 }
Beispiel #4
0
        /// <summary>
        /// Sends a UAVParameter to all clients
        /// </summary>
        /// <param name="param"></param>
        public void Send(UAVSingleParameter param)
        {
            foreach (TcpClient myclient in clients)
            {
                if (myclient.Connected)
                {
                    if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US")
                    {

                        System.Threading.Thread.CurrentThread.CurrentCulture = new
            System.Globalization.CultureInfo("en-US");
                    }
                       NetworkStream clientStream = myclient.GetStream();
                    UTF8Encoding encoder = new UTF8Encoding();
                    byte[] buffer = encoder.GetBytes(param.GetStringPath() + "|" + DateTime.UtcNow.Ticks.ToString() + "|" + param.Value.ToString() + "\n");
                    clientStream.Write(buffer, 0, buffer.Length);
                    clientStream.Flush();
                }
            }
        }
Beispiel #5
0
        public static void NormaliseStructure(UAVSingleParameter param, List<UAVSingleParameter> remotedata)
        {
            if (param is UAVStructure)
            {
                UAVStructure mystructure = ((UAVStructure)param);
                foreach (UAVSingleParameter myparams in mystructure.values.Values)
                {
                    if (myparams is UAVStructure)
                    {
                        NormaliseStructure(myparams, remotedata);
                        UAVSingleParameter temp = new UAVSingleParameter(myparams.GetStringPath(), myparams.Value);
                        temp.Max = myparams.Max;
                        temp.Min = myparams.Min;
                        temp.updateRate = myparams.updateRate;
                        temp.Value = myparams.Value;
                        remotedata.Add(temp);
                    }
                    else
                    {
                        UAVSingleParameter temp = new UAVSingleParameter(myparams.GetStringPath(), myparams.Value);
                        temp.Max = myparams.Max;
                        temp.Min = myparams.Min;
                       // temp.Value = myparams.Value;
                        temp.updateRate = myparams.updateRate;
                        remotedata.Add(temp);
                    }
                }
                //Eigen Wert

                UAVSingleParameter temp2 = new UAVSingleParameter(param.GetStringPath(), param.Value);
                temp2.Max = param.Max;
                temp2.Min = param.Min;
                // temp.Value = myparams.Value;
                temp2.updateRate = param.updateRate;
                remotedata.Add(temp2);

            }
            else
                if (param is UAVSingleParameter)
                {
                    UAVSingleParameter newparam = new UAVSingleParameter(param.Name, param.Value);
                    newparam.Name = param.GetStringPath();
                    newparam.Min = param.Min;
                    newparam.Max = param.Max;
                    //  if (!(param.Parent is UAVBase))
                    //   {
                    //      newparam.Parent = param.Parent;
                    //    }
                    newparam.updateRate = param.updateRate;
                    newparam.Value = param.Value;
                    remotedata.Add(newparam);
                }
        }
Beispiel #6
0
        public void Send(UAVSingleParameter param)
        {
            if (param.Value == null) return;
            lock (SendSync)
            {
                if (client != null)
                {
                    UTF8Encoding encoder = new UTF8Encoding();
                    byte[] buffer = encoder.GetBytes(param.GetStringPath() + "|" + DateTime.UtcNow.Ticks.ToString() + "|" + param.Value.ToString() + "\n");
                    client.Send(buffer, buffer.Length);

                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Sieht nach welcher Parameter in wie abgelegt werden soll
        /// </summary>
        /// <param name="param"></param>
        /// <param name="isremote"></param>
        void Source_ValueChanged(UAVSingleParameter param, bool isremote)
        {
            if (param.GetStringPath() == GetStringPath()) return;
            lock (Syncobj)
            {

               //     Console.WriteLine(param.Name + " " + param.Value);
                if (mapping.ContainsKey(param.Name))
                {
                    if (values.ContainsKey(mapping[param.Name])){
                        if (values[mapping[param.Name]].GetStringPath() != param.GetStringPath()) {
                        values[mapping[param.Name]].Value = param.Value;
                        }
                    }else{

                        values.Add(mapping[param.Name],new UAVParameter(mapping[param.Name],param.Value,param.Min, param.Max));
                        values[mapping[param.Name]].updateRate = 40;
                    }
                }
            }
        }
Beispiel #8
0
 public void Send(UAVSingleParameter param)
 {
     if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US")
     {
         System.Threading.Thread.CurrentThread.CurrentCulture = new
     System.Globalization.CultureInfo("en-US");
     }
     if (param.Value == null) return;
     lock (SendSync)
     {
         if (clientStream != null)
         {
             UTF8Encoding encoder = new UTF8Encoding();
             byte[] buffer = encoder.GetBytes(param.GetStringPath() + "|" + DateTime.UtcNow.Ticks.ToString() + "|" + param.Value.ToString() + "\n");
             clientStream.Write(buffer, 0, buffer.Length);
             clientStream.Flush();
         }
     }
 }