public string ToLine()
 {
     return("D1"
            + $"{Field1.ToFixedString(10)}"
            + $"{Field2.ToFixedString(10)}"
            + $"{Field3.ToFixedString(10)}"
            + $"{Field4.ToFixedString(10)}"
            + $"{Field5.ToFixedStringRight(10, '0')}"
            + "");
 }
        protected override void Execute(CodeActivityContext context)
        {
            //Channel Details
            var writeKey = Write_API_Key.Get(context);

            //Field Values
            var f1 = Field1.Get(context) != null ? "&field1=" + Field1.Get(context) : "";
            var f2 = Field2.Get(context) != null ? "&field2=" + Field2.Get(context) : "";
            var f3 = Field3.Get(context) != null ? "&field3=" + Field3.Get(context) : "";
            var f4 = Field4.Get(context) != null ? "&field4=" + Field4.Get(context) : "";
            var f5 = Field5.Get(context) != null ? "&field5=" + Field5.Get(context) : "";
            var f6 = Field6.Get(context) != null ? "&field6=" + Field6.Get(context) : "";
            var f7 = Field7.Get(context) != null ? "&field7=" + Field7.Get(context) : "";
            var f8 = Field8.Get(context) != null ? "&field8=" + Field8.Get(context) : "";

            var chosenFormat = Format.GetHashCode() == 0 ? "" : "." + Format.ToString();

            //Optional Parameters
            var lat        = Lat.Get(context) == 0 ? "" : "&lat=" + Lat.Get(context).ToString();
            var lon        = Long.Get(context) == 0 ? "" : "&long=" + Long.Get(context).ToString();
            var elevation  = Elevation.Get(context) == 0 ? "" : "&elevation=" + Elevation.Get(context).ToString();
            var status     = Status.Get(context) == null ? "" : "&status=" + Status.Get(context);
            var twitter    = Twitter.Get(context) == null ? "" : "&twitter=" + Twitter.Get(context);
            var tweet      = Tweet.Get(context) == null ? "" : "&tweet=" + Tweet.Get(context);
            var created_at = Created_at.Get(context) == null ? "" : "&created_at=" + Created_at.Get(context);


            //Http Request URL
            string URL = "https://api.thingspeak.com/update" + chosenFormat + "?api_key=" + writeKey;

            URL = URL + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + lat + lon + elevation + status + twitter + tweet + created_at;

            //Creating GET Http Request
            WebRequest   wrGETURL  = WebRequest.Create(URL);
            Stream       objStream = wrGETURL.GetResponse().GetResponseStream();
            StreamReader objReader = new StreamReader(objStream);

            //Capturing the response
            string sLine        = "";
            string httpResponse = "";

            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                {
                    httpResponse = httpResponse + sLine + "\n";
                }
            }
            objStream.Close();
            //objReader.Close();
            Response.Set(context, httpResponse);
        }
Пример #3
0
        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9);
            bool isNumeric       = (e.Key >= Key.D0 && e.Key <= Key.D9);

            Key[] keysToFilter = { Key.Delete, Key.Back, Key.Left, Key.Right, Key.Tab };
            if (!isNumeric && !isNumPadNumeric && !keysToFilter.Contains(e.Key))
            {
                e.Handled = true;
                return;
            }

            if ((e.Key == Key.Right && (sender as TextBox).CaretIndex == (sender as TextBox).Text.Length))
            {
                if (sender == Field1)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field4.Focus();
                }

                e.Handled = true;
            }
            else if (e.Key == Key.Left && (sender as TextBox).CaretIndex == 0)
            {
                if (sender == Field4)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field1.Focus();
                }

                e.Handled = true;
            }
            else if (e.Key == Key.OemMinus)
            {
                e.Handled = true;
            }
        }
 /// <summary>
 /// Update species fact fields with latest red list values.
 /// </summary>
 protected override void SetReadListValues()
 {
     if (AllowAutomaticUpdate)
     {
         if (RedListCalculator.IsEvaluationStatusSet)
         {
             Field4.SetValueAutomatic(Criteria);
         }
         else
         {
             // Reset values to nothing.
             Field4.SetValueAutomatic(null);
         }
     }
 }
        /// <summary>
        /// Update species fact fields with latest red list values.
        /// </summary>
        protected override void SetReadListValues()
        {
            if (AllowAutomaticUpdate)
            {
                Factor factor;

                if (RedListCalculator.IsEvaluationStatusSet)
                {
                    factor = FactorManager.GetFactor((Int32)FactorId.RedListCategoryAutomatic);
                    foreach (FactorFieldEnumValue enumValue in factor.FactorDataType.Fields[0].FactorFieldEnum.Values)
                    {
                        if (enumValue.KeyInt == ((Int32)Category))
                        {
                            Field1.SetValueAutomatic(enumValue);
                            break;
                        }
                    }
                    Field2.SetValueAutomatic(RedListCalculator.IsGraded);
                    if (RedListCalculator.IsGraded &&
                        ((Category == RedListCategory.CR) ||
                         (Category == RedListCategory.EN) ||
                         (Category == RedListCategory.VU) ||
                         (Category == RedListCategory.NT) ||
                         (Category == RedListCategory.LC)) &&
                        !(((RedListCalculator.CategoryProbableNoGrading == RedListCategory.NT) ||
                           (RedListCalculator.CategoryProbableNoGrading == RedListCategory.LC)) &&
                          (RedListCalculator.CategoryProbableGraded == RedListCategory.LC) &&
                          (Category == RedListCategory.NT) &&
                          RedListCalculator.IsConservationDependent))
                    {
                        Field4.SetValueAutomatic(Category.ToString() + "°");
                    }
                    else
                    {
                        Field4.SetValueAutomatic(Category.ToString());
                    }
                }
                else
                {
                    // Reset values to nothing.
                    Field1.SetValueAutomatic(null);
                    Field2.SetValueAutomatic(null);
                    Field4.SetValueAutomatic(null);
                }
            }
        }
Пример #6
0
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            var tbx = sender as TextBox;

            byte value = 0;

            if (!string.IsNullOrEmpty(tbx.Text) && !Byte.TryParse(tbx.Text, out value))
            {
                tbx.Text = "255";

                if (sender == Field1)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field4.Focus();
                }
            }
            else if (tbx.Text.Length == 3)
            {
                if (sender == Field1)
                {
                    Field2.Focus();
                }
                else if (sender == Field2)
                {
                    Field3.Focus();
                }
                else if (sender == Field3)
                {
                    Field4.Focus();
                }
            }

            SetValue(ValueProperty, string.Format("{0}.{1}.{2}.{3}", Field1.Text, Field2.Text, Field3.Text, Field4.Text));
        }
Пример #7
0
        void ReleaseDesignerOutlets()
        {
            if (Field0 != null)
            {
                Field0.Dispose();
                Field0 = null;
            }

            if (Field1 != null)
            {
                Field1.Dispose();
                Field1 = null;
            }

            if (Field2 != null)
            {
                Field2.Dispose();
                Field2 = null;
            }

            if (Field3 != null)
            {
                Field3.Dispose();
                Field3 = null;
            }

            if (Field4 != null)
            {
                Field4.Dispose();
                Field4 = null;
            }

            if (Label0 != null)
            {
                Label0.Dispose();
                Label0 = null;
            }

            if (Label1 != null)
            {
                Label1.Dispose();
                Label1 = null;
            }

            if (Label2 != null)
            {
                Label2.Dispose();
                Label2 = null;
            }

            if (Label3 != null)
            {
                Label3.Dispose();
                Label3 = null;
            }

            if (Label4 != null)
            {
                Label4.Dispose();
                Label4 = null;
            }
        }
Пример #8
0
        public override string ToString()
        {
            string content = "当前状态 : " + FaultTitle + "\r\n太阳能电压 : " + Field1.ToString("0.00") + " V\r\n超容电压 : " + Field2.ToString("0.00") + " V\r\n超容电流 : " + Field3.ToString("0.00") + " A\r\n功率 : " + Field4.ToString("0.00") + " W\r\n温度 : " + Field5.ToString("0.00") + " ℃";

            if (Field6 > 100)
            {
                content += "\r\n更新时间 : " + CreateTime;
            }
            else
            {
                content += "\r\n超容余量 : " + Field6.ToString("0.00") + " %\r\n更新时间 : " + CreateTime;
            }
            return(content);
        }
Пример #9
0
        public string ToOldString()
        {
            string content = "当前状态 : " + FaultTitle + "\r\n太阳能电压 : " + Field1.ToString("0.00") + " V\r\n超容电压 : " + Field2.ToString("0.00") + " V\r\n超容电流 : " + Field3.ToString("0.00") + " A\r\n功率 : " + Field4.ToString("0.00") + " W\r\n温度 : " + Field5.ToString("0.00") + " ℃";

            content += "\r\n更新时间 : " + CreateTime;

            return(content);
        }