Exemplo n.º 1
0
        public void ParseIntoSubStrings(AnQueueString queue_string_)
        {
            Debug.Assert(!string.IsNullOrEmpty(queue_string_.DATA_STRING));

            queue_string = queue_string_;

            indexing_start_end_string(queue_string);
        }
        public AcsDataMessage ParseMessageString(AnQueueString anQueueDataBytes_)
        {
            ACS_MSG_STATE state = ACS_MSG_STATE.AMS_OK_STATE;

            string an_subs_tring = anQueueDataBytes_.DATA_STRING;

            // structDataSrc
            // structStartTime
            // structStartDate
            // structStartIxNum
            // structStartAcsNum


            // 1. check positions

            foreach (StructFieldAcsMsg struct_field in ary_StructFieldAcsMsg)
            {
                if (an_subs_tring.Length > struct_field.sign_position)
                {
                    if (struct_field.sign_ != (char)an_subs_tring[struct_field.sign_position])
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }

            // 2. Retreive data
            foreach (StructFieldAcsMsg struct_acs_msg in ary_StructFieldAcsMsg)
            {
                int start  = struct_acs_msg.sign_position + 1;
                int end    = start + struct_acs_msg.data_length;
                int ix_ary = 0;

                if (an_subs_tring.Length >= end)
                {
                    for (int ix = start; ix < end; ix++)
                    {
                        struct_acs_msg.ary_chars[ix_ary++] = an_subs_tring[ix];
                    }
                }
                else
                {
                    return(null);
                }
            }


            return(new AcsDataMessage(ary_StructFieldAcsMsg));
        }
Exemplo n.º 3
0
 /// <summary>
 /// return null in case uart_string_queue is empty
 /// make a copy for output
 /// </summary>
 /// <returns>sended from UART data as string or null</returns>
 public AnQueueString GetUartDataStringWithOutputCopy()
 {
     if (IS_UART_STRING_QUEUE_INPUT_NOT_EMPTY)
     {
         AnQueueString qs = uart_string_queue_input.Dequeue();
         uart_string_queue_output.Enqueue(qs);
         return(qs);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 4
0
        void indexing_start_end_string(AnQueueString queue_string_)
        {
            for (int ix = 0; ix < queue_string_.DATA_LENGTH; ix++)
            {
                schemaSubString.CheckChar(queue_string_.DATA_STRING[ix]);

                if (schemaSubString.IS_SUCCESSFULLY_COMPLETED)
                {
                    AnQueueString an_queue_string = new AnQueueString(schemaSubString.CUR_SUB_STRING, queue_string_.DATE_TIME, BUFFER_DATA_TYPE.BFDT_SUB_STRING);

                    on_substring_completed(an_queue_string);

                    schemaSubString.Reset();
                }
                else if (schemaSubString.IS_ERROR_STATE)
                {
                    AnQueueString an_queue_string = new AnQueueString(schemaSubString.CUR_SUB_STRING, queue_string_.DATE_TIME, BUFFER_DATA_TYPE.BFDT_ERR_STRING);

                    on_substring_error(an_queue_string);

                    schemaSubString.Reset();
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// store sended from UART data as string
 /// </summary>
 /// <param name="str_new_data_"></param>
 public void AddUartDataString(AnQueueString new_q_bytes)
 {
     Debug.Assert(!string.IsNullOrEmpty(new_q_bytes.DATA_STRING));
     uart_string_queue_input.Enqueue(new_q_bytes);
 }
Exemplo n.º 6
0
 /// <summary>
 /// store selected from UART sub_string
 /// </summary>
 /// <param name="str_new_msg_"></param>
 public void AddErrSubString(AnQueueString new_q_err_substr)
 {
     Debug.Assert(!string.IsNullOrEmpty(new_q_err_substr.DATA_STRING));
     err_string_queue_output.Enqueue(new_q_err_substr);
 }
Exemplo n.º 7
0
 /// <summary>
 /// store selected from UART sub_string
 /// </summary>
 /// <param name="str_new_msg_"></param>
 public void AddCompletedSubString(AnQueueString new_q_substr)
 {
     Debug.Assert(!string.IsNullOrEmpty(new_q_substr.DATA_STRING));
     sub_string_queue_output.Enqueue(new_q_substr);
 }
Exemplo n.º 8
0
 public AnQueueStringArg(AnQueueString an_queue_string_)
 {
     an_queue_string = an_queue_string_;
 }
Exemplo n.º 9
0
        void on_substring_error(AnQueueString q_errstring_bytes_)
        {
            EventHandler <AnQueueStringArg> subStringError = errorSubString;

            subStringError?.Invoke(this, new AnQueueStringArg(q_errstring_bytes_));
        }
Exemplo n.º 10
0
        void on_substring_completed(AnQueueString q_substring_bytes_)
        {
            EventHandler <AnQueueStringArg> subStringCompleted = completedSubString;

            subStringCompleted?.Invoke(this, new AnQueueStringArg(q_substring_bytes_));
        }