Beispiel #1
0
 public override bool SendValues(ChannelValues values)
 {
     if (_targets[currentTarget] != null)
     {
         return(_targets[currentTarget].SendValues(values));
     }
     else
     {
         return(false);
     }
 }
Beispiel #2
0
        public override bool SendValues(ChannelValues values)
        {
            //var client = new RestClient(url);
            var request = new RestRequest(String.Format(apiVarFormattingString, values.isRightChannel?2:6), Method.PUT);

            request.RequestFormat = DataFormat.Json;
            //string jsonString = String.Format(commandFormattingString, ((values.Y + values.B)/2) - 1, getCT(values));
            string jsonString = String.Format(commandFormattingString, Math.Max(values.Y, values.B), getCT(values));

            request.AddParameter("text/json", jsonString, ParameterType.RequestBody);
            var result = client.Execute(request);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                Debug.WriteLine(jsonString);
                return(true);
            }
            else
            {
                Debug.WriteLine(result.ToString());
                return(false);
            }
        }
Beispiel #3
0
 public abstract bool SendValues(ChannelValues values);
Beispiel #4
0
 private double getCT(ChannelValues values)
 {
     //return 326 + 173 * (values.Y - values.B) / 255; /*210*/  /*60*/ /*mid=135*/
     return(Convert.ToUInt16(153 + 347 * (Math.Atan2(values.Y, values.B) * (180 / Math.PI)) / 90)); /*210*/  /*60*/ /*mid=135*/
 }