Пример #1
0
        static public void REVERSER_EVENT()
        {
            int objectID = (int)ControlObjectsList.REVERSER;

            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.REVERSER, 0);
                return;
            }
            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.POWER) != 0)
            {
                return;
            }

            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.REVERSER, Int32.Parse(controlObjectsInfo[objectID].objectData[2]));
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[1]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.REVERSER, Int32.Parse(controlObjectsInfo[objectID].objectData[4]));
            }
            else
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.REVERSER, Int32.Parse(controlObjectsInfo[objectID].objectData[3]));
            }
        }
Пример #2
0
        static public void TRACTION_EVENT()
        {
            int objectID = (int)ControlObjectsList.TRACTION;

            // Hack: If Traction Switch Doesn't Enable
            if (!controlObjectArrange[objectID].objectEnable)
            {
                return;
            }

            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.PANTO_UP) == 0)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.TRACTION_ON, 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1], 0);
                return;
            }
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.TRACTION_ON, 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1], 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.TRACTION_ON, 1);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1], 1);
            }
        }
Пример #3
0
        static public void DEADMAN_EVENT()
        {
            int objectID = (int)ControlObjectsList.DEADMAN;

            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.PANTO_UP) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.TRACTION_ON) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.SPEED) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.EMERGENCY) == 1 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.DEADMAN_ENABLE_TRIG) == 0 ||
                !controlObjectArrange[objectID].objectEnable)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.DEADMAN_ENABLE, 0);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.DEADMAN_PRESS, 1);
                return;
            }
            DataManager.SetTrainData((int)DataManager.TrainDataMap.DEADMAN_ENABLE, 1);
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.DEADMAN_PRESS, 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.DEADMAN_PRESS, 1);
            }
        }
Пример #4
0
        static public void DOOR_EVENT()
        {
            int objectID = (int)ControlObjectsList.DOOR;

            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.LDOOR_OPEN, 0);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.RDOOR_OPEN, 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2], 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3], 0);
                return;
            }
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.LDOOR_OPEN, 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2], 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.LDOOR_OPEN, 1);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2], 1);
            }
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[1]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.RDOOR_OPEN, 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3], 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[1]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.RDOOR_OPEN, 1);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3], 1);
            }
        }
Пример #5
0
        static public void MASTER_KEY_EVENT()
        {
            int objectID = (int)ControlObjectsList.MASTER_KEY;

            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.MASTER_KEY, 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.MASTER_KEY, 1);
            }
        }
Пример #6
0
        static public void EMERGENCY_EVENT()
        {
            int objectID = (int)ControlObjectsList.EMERGENCY;

            if (!controlObjectArrange[objectID].objectEnable)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.EMERGENCY, 0);
                return;
            }
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.EMERGENCY, 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.EMERGENCY, 1);
            }
        }
Пример #7
0
        static public void AIR_CONDITION_EVENT()
        {
            int objectID = (int)ControlObjectsList.AIR_CONDITION;

            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0 ||
                !controlObjectArrange[objectID].objectEnable)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.AIR_CONDITION_ON, 0);
                return;
            }
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.AIR_CONDITION_ON, 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.AIR_CONDITION_ON, 1);
            }
        }
Пример #8
0
        static public void CAB_SIGNAL_EVENT()
        {
            int objectID = (int)ControlObjectsList.CAB_SIGNAL;

            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0 ||
                !controlObjectArrange[objectID].objectEnable)
            {
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[0], 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1], 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2], 0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3], 0);
                return;
            }
            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.SIGNAL) > 2)
            {
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[0],1);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3],0);
            }
            else if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.SIGNAL) == 2)
            {
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[0],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1],1);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3],0);
            }
            else if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.SIGNAL) == 1)
            {
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[0],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2],1);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3],0);
            }
            else if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.SIGNAL) == 0)
            {
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[0],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[1],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[2],0);
                DevicesManager.SetDeviceValue((int)controlObjectArrange[objectID].objectIO[3],1);
            }
        }
Пример #9
0
        static public void ATC_EVENT()
        {
            int objectID = (int)ControlObjectsList.ATC;

            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.PANTO_UP) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.TRACTION_ON) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.EMERGENCY) == 1 ||
                !controlObjectArrange[objectID].objectEnable)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.SPEED_CONST, 0);
                return;
            }
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[0]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.SPEED_CONST, 0);
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.SPEED_CONST, 1);
            }
        }
Пример #10
0
        static public void COMBINED_HANDLE_EVENT()
        {
            bool zeroPaused = false;
            int  objectID   = (int)ControlObjectsList.COMBINED_HANDLE;
            int  tractionID = (int)ControlObjectsList.TRACTION;

HandleCheck:
            if ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.MASTER_KEY) == 0 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.PANTO_UP) == 0 ||
                ((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.TRACTION_ON) == 0 && controlObjectArrange[tractionID].objectEnable) ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.EMERGENCY) == 1 ||
                (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.REVERSER) == 0)
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 0);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 6);
                return;
            }
            if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[0]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 1);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 0);
                return;
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[1]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 2);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 0);
                return;
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[2]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 3);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 0);
                return;
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[3]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 0);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 2);
                return;
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[4]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 0);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 4);
                return;
            }
            else if (DevicesManager.GetDeviceValue((int)controlObjectArrange[objectID].objectIO[5]) == Int32.Parse(controlObjectsInfo[objectID].objectData[1]))
            {
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 0);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 6);
                return;
            }
            else
            {
                // Hack If Last Time Not P1 or B1
                if (((int)DataManager.GetTrainData((int)DataManager.TrainDataMap.POWER) > 1 ||
                     (int)DataManager.GetTrainData((int)DataManager.TrainDataMap.BRAKE) > 2) && !zeroPaused)
                {
                    Thread.Sleep(200);
                    zeroPaused = true;
                    goto HandleCheck;
                }
                DataManager.SetTrainData((int)DataManager.TrainDataMap.POWER, 0);
                DataManager.SetTrainData((int)DataManager.TrainDataMap.BRAKE, 0);
                zeroPaused = false;
                return;
            }
        }
Пример #11
0
        static public void ProjectLoaderProcess(LoadingState processValue)
        {
            try
            {
                switch (processValue)
                {
                case LoadingState.WAIT_FOR_START:
                {
                    ProcessEvent(LoadingState.READY);
                    break;
                }

                case LoadingState.READY:
                {
                    //reset data
                    BoardsManager.ResetBoardManager();
                    ControlObjects.ResetControlObjects();
                    CommunicationSerial.ResetSerial();
                    DataManager.ResetTrainData();
                    PackagesManager.ResetPackageManager();
                    GraphicOptionsManager.ResetGraphicOptionsManager();
                    UserInterfaceSwap.errorContent.Clear();
                    RProxy.SimWorldTrigger.ResetTrigger();
                    ProcessEvent(LoadingState.DATA_RESET);
                    break;
                }

                case LoadingState.DATA_RESET:
                {
                    //update list
                    SettingsContent.UpdateSettingsPath();
                    BoardsManager.UpdateBoardItems();
                    ControlObjects.UpdateControlObjectsItem();
                    ProjectsManager.UpdateProjectItem();
                    PackagesManager.UpdatePackageList();
                    ProcessEvent(LoadingState.DATA_UPDATED);
                    break;
                }

                case LoadingState.DATA_UPDATED:
                {
                    //get project define file path
                    int fileIndex = ProjectsManager.projectList.projectID.IndexOf(projectGUIDValue);
                    projectFilePath = ProjectsManager.projectList.projectFilePath[fileIndex];
                    projectDirPath  = Path.GetDirectoryName(projectFilePath);
                    //load project define file
                    ProjectsManager.LoadProjectFile(projectFilePath);
                    ProjectsManager.SetupBoard();
                    ProjectsManager.SetupControlObjects();
                    DevicesManager.UpdateDevicesInitMode();
                    CommunicationSerial.InitializeSerial();
                    ProcessEvent(LoadingState.PROJECT_DEFINE_LOADED);
                    break;
                }

                case LoadingState.PROJECT_DEFINE_LOADED:
                {
                    //load package
                    PackagesManager.LoadPackageFile(ProjectsManager.projectInfo.packageGUID);
                    ProcessEvent(LoadingState.PACKAGE_DEFINE_LOADED);
                    break;
                }

                case LoadingState.PACKAGE_DEFINE_LOADED:
                {
                    //load train
                    PackagesManager.packageInfo.trainDetailInfoLoaded = false;
                    LoadTrainData(PackagesManager.packageInfo.packageTrainDir);
                    ProcessEvent(LoadingState.TRAIN_LOADED);
                    break;
                }

                case LoadingState.TRAIN_LOADED:
                {
                    //load route
                    PackagesManager.packageInfo.routeDetailInfoLoaded = false;
                    routeLoadingStateMonitor.AttachMainTimerInterrupt();
                    routeLoadingStateMonitor.MainTimerEnable = true;
                    LoadRouteData(PackagesManager.packageInfo.packageRouteDir);
                    break;
                }

                case LoadingState.ROUTE_LOADED:
                {
                    //load options
                    GraphicOptionsManager.LoadGraphicOptionsFile(ProjectsManager.projectInfo.simulatorOptionsFilePath);
                    GraphicOptionsLoaderEvent(GraphicOptionsManager.graphicOptionsValue);
                    ProcessEvent(LoadingState.SIM_OPTIONS_LOADED);
                    break;
                }

                case LoadingState.SIM_OPTIONS_LOADED:
                {
                    //check error
                    UserInterfaceSwap.errorContent = ProjectsManager.CheckProjectContent();
                    ProcessEvent(LoadingState.DATA_SERVER_START);
                    break;
                }

                case LoadingState.DATA_SERVER_START:
                {
                    //starting server
                    ProjectsManager.SetupDataServer();
                    ProcessEvent(LoadingState.DONE);
                    break;
                }

                case LoadingState.DONE:
                {
                    CommunicationNetwork.StartWebSocketServer();
                    StartSimulatorEvent();
                    break;
                }
                }
            }
            catch (Exception)
            {
                ProcessEvent(LoadingState.ERROR);
            };
        }
Пример #12
0
        static public void BoardSerialStreamDoEvents(string dataStream)
        {
            bool getDataToConnect = BoardStreamCommonFunctions.SpecialSymbolRepeatTime(dataStream, BoardsManager.boardInfo.COMM_CONNECT_SPEC_NUM);

            if (communicationStateList[0] != CommunicationState.STATE1 && getDataToConnect)
            {
                BoardStreamCommonFunctions.specialDataExpected = false;
                communicationStateList[0] = CommunicationState.STATE1;
            }
            if (communicationStateList[0] == CommunicationState.STATE1 && !getDataToConnect)
            {
                BoardStreamCommonFunctions.SendSpecialData(BoardsManager.boardInfo.COMM_RESET_SPEC_NUM);
                BoardStreamCommonFunctions.specialDataExpected = false;
                communicationStateList[0] = CommunicationState.STATE1;
            }
startPoint:
            if (communicationStateList[0] == CommunicationState.STATE1)
            {
                if (!BoardStreamCommonFunctions.specialDataExpected)
                {
                    BoardStreamCommonFunctions.SetSpecialDataExpect(BoardsManager.boardInfo.COMM_CONNECT_SPEC_NUM);
                }

                if (BoardStreamCommonFunctions.SpecialSymbolRepeatTime(dataStream, BoardStreamCommonFunctions.expectSpecialDataNum))
                {
                    BoardStreamCommonFunctions.devicesConfigFlashed    = false;
                    BoardStreamCommonFunctions.specialDataExpected     = false;
                    BoardStreamCommonFunctions.inProcessSendDiviedPack = false;
                    BoardStreamCommonFunctions.SendSpecialData(BoardsManager.boardInfo.COMM_CONNECT_SPEC_NUM);
                    Thread.Sleep(200);
                    communicationStateList[0] = CommunicationState.STATE2;
                    goto startPoint;
                }
                return;
            }
            else if (communicationStateList[0] == CommunicationState.STATE2)
            {
                //Send setup data
                if (!BoardStreamCommonFunctions.devicesConfigFlashed)
                {
                    if (!BoardStreamCommonFunctions.inProcessSendDiviedPack)
                    {
                        BoardStreamCommonFunctions.SendSpecialData(BoardsManager.boardInfo.COMM_CLEAR_DEVICES_STATE_NUM);
                        Thread.Sleep(200);
                        diviedDataStream.Clear();
                        diviedDataStream             = BoardStreamCommonFunctions.GetDiviedDataPack(DevicesManager.GetDevicesSetupDataStream());
                        divedDataStreamCount         = diviedDataStream.Count;
                        divedDataStreamCurrentSendID = 0;
                        BoardStreamCommonFunctions.inProcessSendDiviedPack = true;
                    }
                    if (divedDataStreamCount > 0)
                    {
                        SendDataViaSerial(0, diviedDataStream[divedDataStreamCurrentSendID]);
                        divedDataStreamCurrentSendID++;
                        divedDataStreamCount--;
                        communicationStateList[0] = CommunicationState.STATE3;
                        BoardStreamCommonFunctions.SetSpecialDataExpect(BoardsManager.boardInfo.COMM_CONTINUE_SPEC_NUM);
                        return;
                    }
                    BoardStreamCommonFunctions.SendSpecialData(BoardsManager.boardInfo.COMM_TRANSEND_SPEC_NUM);
                    diviedDataStream.Clear();
                    BoardStreamCommonFunctions.inProcessSendDiviedPack = false;
                    BoardStreamCommonFunctions.specialDataExpected     = false;
                    BoardStreamCommonFunctions.devicesConfigFlashed    = true;
                    communicationStateList[0] = CommunicationState.STATE3;
                    return;
                }
                //Send device data
                if (!BoardStreamCommonFunctions.inProcessSendDiviedPack)
                {
                    diviedDataStream.Clear();
                    diviedDataStream             = BoardStreamCommonFunctions.GetDiviedDataPack(DevicesManager.GetDevicesDataStream());
                    divedDataStreamCount         = diviedDataStream.Count;
                    divedDataStreamCurrentSendID = 0;
                    BoardStreamCommonFunctions.inProcessSendDiviedPack = true;
                }
                if (divedDataStreamCount > 0)
                {
                    SendDataViaSerial(0, diviedDataStream[divedDataStreamCurrentSendID]);
                    divedDataStreamCurrentSendID++;
                    divedDataStreamCount--;
                    communicationStateList[0] = CommunicationState.STATE3;
                    BoardStreamCommonFunctions.SetSpecialDataExpect(BoardsManager.boardInfo.COMM_CONTINUE_SPEC_NUM);
                    return;
                }
                BoardStreamCommonFunctions.SendSpecialData(BoardsManager.boardInfo.COMM_TRANSEND_SPEC_NUM);
                diviedDataStream.Clear();
                BoardStreamCommonFunctions.inProcessSendDiviedPack = false;
                BoardStreamCommonFunctions.specialDataExpected     = false;
                BoardStreamCommonFunctions.devicesConfigFlashed    = true;
                communicationStateList[0] = CommunicationState.STATE3;
                return;
            }
            if (communicationStateList[0] == CommunicationState.STATE3)
            {
                if (BoardStreamCommonFunctions.specialDataExpected &&
                    BoardStreamCommonFunctions.SpecialSymbolRepeatTime(dataStream, BoardStreamCommonFunctions.expectSpecialDataNum))
                {
                    BoardStreamCommonFunctions.specialDataExpected = false;
                    communicationStateList[0] = CommunicationState.STATE2;
                    goto startPoint;
                }
                //Get board devices value
                if (BoardStreamCommonFunctions.SpecialSymbolRepeatTime(dataStream, BoardsManager.boardInfo.COMM_TRANSEND_SPEC_NUM))
                {
                    communicationStateList[0] = CommunicationState.STATE2;
                    goto startPoint;
                }
                DevicesManager.BoardStreamToDevicesValue(dataStream);
                DevicesManager.BoardStreamToDevicesApply();
                BoardStreamCommonFunctions.SendSpecialData(BoardsManager.boardInfo.COMM_CONTINUE_SPEC_NUM);
                return;
            }
        }