Beispiel #1
0
 public IEnumerator <ITask> ReplaceHandler(Replace replace)
 {
     ProcessConfigurationString(ref _state, replace.Body.configuration);
     replace.ResponsePort.Post(new dssp.DefaultReplaceResponseType());
     _subMgrPort.Post(new submgr.Submit(_state, DsspActions.ReplaceRequest));
     _state = replace.Body;
     yield break;
 }
Beispiel #2
0
        /// <summary>
        /// Process configuration string
        /// </summary>
        /// <param name="state"></param>
        /// <param name="body"></param>
        void ProcessConfigurationString(ref AnalogActuatorState state, string body)
        {
            if ((body != null) && (body.Length > 0))
            {
                string[] sections = body.Split(new char[] { '&' });

                foreach (string rawPair in sections)
                {
                    string[] keyValuePair = rawPair.Split(new char[] { '=' }, 2);

                    if (keyValuePair.Length == 2)
                    {
                        string key   = Uri.UnescapeDataString(keyValuePair[0]).ToUpper();
                        string value = Uri.UnescapeDataString(keyValuePair[1]);
                        if (0 == key.CompareTo("ACTUATORINIT"))
                        {
                            // ACTUATORINIT=_index_,_name_,_value_

                            string[] indexAttrib = value.Split(new char[] { ',' });

                            int actuatorID = Convert.ToInt32(indexAttrib[0]);

                            if ((actuatorID > 0) && (actuatorID <= 2) && (indexAttrib.Length == 3))
                            {
                                UpdateActuatorConfiguration(
                                    actuatorID,
                                    indexAttrib[1].ToString(),
                                    Convert.ToInt32(indexAttrib[2]));
                            }
                        }
                        else if (0 == key.CompareTo("ACTUATORSET"))
                        {
                            // ACTUATORSET=_value1_,_value2_,_value3_

                            string[] indexAttrib = value.Split(new char[] { ',' });

                            if (indexAttrib.Length == 3)
                            {
                                for (int i = 0; i < 3; i++)
                                {
                                    SetActuator_Value(i + 1, Convert.ToInt32(indexAttrib[i]));
                                }
                            }
                        }
                    }
                }
            }
        }