示例#1
0
    private void SendText(string text)

    {
        inject.text   = string.Empty;
        console.text += "\n" + text + " ~ sent to command handler";
        inject.Select();
        inject.ActivateInputField();
        PanelHandler ph = PanelHanderObj.GetComponent <PanelHandler>();

        string[] command = text.Split(new char[0]); //splits text into array by spaces

        char triggerChar       = '!';
        bool commandSuccessful = true;
        bool displayMsg        = true;

        if (text[0].Equals(triggerChar))
        {
            switch (command[0])
            {
            case "!exec":
                //call execution system.
                string   processblock   = writesheet.text;
                string[] execCommandLbL = Regex.Split(processblock, "\r\n");
                for (int ia = 0; ia < execCommandLbL.Length; ia++)
                {
                    SendText(execCommandLbL[ia]);
                    console.text += "Processing " + execCommandLbL[ia];
                }
                break;

            case "!execMode":
                switch (command[1])
                {
                case "block":
                    lineByLine = false;
                    break;
                }

                break;

            case "!viewPane":
                switch (command[1])
                {
                case "DRAM":
                    ph.ShowDRAMPane();
                    break;

                case "CPU":
                    ph.ShowSCHEMPane();
                    break;

                case "GPRAH":
                    ph.ShowGRAPHPane();
                    break;
                }
                break;

            case "!del":
                switch (command[1])
                {
                case "line":
                    //delete line at command[2]
                    break;

                case "writesheet":
                    //ask if user is sure
                    //delete entire writesheet
                    writesheet.text = null;
                    break;

                case "console":
                    console.text = null;
                    displayMsg   = false;
                    break;
                }
                break;

            case "!repost":
                //reboot vm
                break;

            case "!parameter":
                switch (command[2])
                {
                case "Core0Temp":
                    //edit Core0Temp;
                    changeParameter(command, Core0Temp);
                    break;

                case "PDU0Temp":
                    //edit PDU0Temp
                    changeParameter(command, PDU0Temp);
                    break;

                case "PDU1Temp":
                    //edit PDU1Temp
                    changeParameter(command, PDU1Temp);
                    break;

                case "FPGATemp":
                    //edit FPGATemp;
                    changeParameter(command, FPGATemp);
                    break;

                case "CoreVoltage":
                    //edit CoreVoltage
                    changeParameter(command, CoreVoltage);
                    CVSlider.value = float.Parse(command[3]);
                    break;

                case "PowerLimit":
                    //edit PowerLimit;
                    changeParameter(command, PowerLimit);
                    PLSlider.value = float.Parse(command[3]);
                    break;

                case "TempLimit":
                    //edit TempLimit
                    changeParameter(command, TempLimit);
                    TLSlider.value = float.Parse(command[3]);
                    break;

                case "CoreClock":
                    //edit CoreClockRate
                    changeParameter(command, CoreClock);
                    CCSlider.value = float.Parse(command[3]);
                    break;

                case "MemoryClock":
                    //edit MemoryClockRate
                    changeParameter(command, MemoryClock);
                    MCSlider.value = float.Parse(command[3]);
                    break;

                case "FanSpeed":
                    //edit FanSpeed
                    changeParameter(command, FanSpeed);
                    FSSlider.value = float.Parse(command[3]);
                    break;

                default:
                    commandSuccessful = false;
                    console.text     += "\n" + "command error - can't find parameter";
                    break;         // all IDXes need non recursive cases for performance
                }
                break;

            default:
                commandSuccessful = false;
                console.text     += "\n" + "command error - can't find command";
                break;
            }
        }
        else
        {
            // parse text and process it as assembly code.
            switch (command[0])
            {
            case ("MOV"):
                MOVFunction(command);
                break;
                //case ("LDA"):
            }
            writesheet.text += "\n" + text;
        }

        if (commandSuccessful && displayMsg)
        {
            console.text += "\n" + text + " ~ completed";
        }
        else if (!displayMsg)
        {
        }
        else
        {
            console.text += "\n" + text + " ~ command rejected";
        }
    }
示例#2
0
    private void SendText(string text)

    {
        console.text += "\n" + text + " ~ sent to command handler";
        PanelHandler ph = PanelHanderObj.GetComponent <PanelHandler>();

        string[] command = text.Split(new char[0]); //splits text into array by spaces

        char triggerChar       = '!';
        bool commandSuccessful = true;
        bool displayMsg        = true;

        if (text[0].Equals(triggerChar))

        {
            switch (command[0])
            {
            case "!exec":
                //call execution system.
                console.text += "\n" + writesheet.text;
                break;

            case "!viewPane":
                switch (command[1])
                {
                case "DRAM":
                    ph.ShowDRAMPane();
                    break;

                case "CPU":
                    ph.ShowSCHEMPane();
                    break;

                case "GPRAH":
                    ph.ShowGRAPHPane();
                    break;
                }
                break;

            case "!del":
                switch (command[1])
                {
                case "line":
                    //delete line at command[2]
                    break;

                case "writesheet":
                    //ask if user is sure
                    //delete entire writesheet
                    writesheet.text = null;
                    break;

                case "console":
                    console.text = null;
                    displayMsg   = false;
                    break;
                }
                break;

            case "!repost":
                //reboot vm
                break;

            case "!parameter":
                switch (command[2])
                {
                case "Core0Temp":
                    //edit Core0Temp;
                    changeParameter(command, Core0Temp);

                    break;

                case "PDU0Temp":
                    //edit PDU0Temp
                    changeParameter(command, PDU0Temp);
                    break;

                case "PDU1Temp":
                    //edit PDU1Temp
                    changeParameter(command, PDU1Temp);
                    break;

                case "FPGATemp":
                    //edit FPGATemp;
                    changeParameter(command, FPGATemp);
                    break;

                case "CoreVoltage":
                    //edit CoreVoltage
                    changeParameter(command, CoreVoltage);
                    CVSlider.value = float.Parse(command[3]);
                    break;

                case "PowerLimit":
                    //edit PowerLimit;
                    changeParameter(command, PowerLimit);
                    PLSlider.value = float.Parse(command[3]);
                    break;

                case "TempLimit":
                    //edit TempLimit
                    changeParameter(command, TempLimit);
                    TLSlider.value = float.Parse(command[3]);
                    break;

                case "CoreClock":
                    //edit CoreClockRate
                    changeParameter(command, CoreClock);
                    CCSlider.value = float.Parse(command[3]);
                    break;

                case "MemoryClock":
                    //edit MemoryClockRate
                    changeParameter(command, MemoryClock);
                    MCSlider.value = float.Parse(command[3]);
                    break;

                case "FanSpeed":
                    //edit FanSpeed
                    changeParameter(command, FanSpeed);
                    FSSlider.value = float.Parse(command[3]);
                    break;

                default:
                    commandSuccessful = false;
                    console.text     += "\n" + "command error - can't find parameter";
                    break;
                }
                break;

            default:
                commandSuccessful = false;
                console.text     += "\n" + "command error - can't find command";
                break;
            }
        }
        else
        {
            // parse text and process it as assembly code.
            switch (command[0])
            {
            case ("MOV"):

                if (command[1][0].ToString().StartsWith('#'.ToString()))
                {                                         // if immediate addressing is used
                    command[1] = command[1].Substring(1); //remove #

                    if (command[2].Length == 2)           //if the register number is less than 10
                    {
                        switch (int.Parse((command[2][1].ToString())))
                        {
                        case 0:
                            assignRegister(0, int.Parse(command[1]));
                            break;

                        case 1:
                            assignRegister(1, int.Parse(command[1]));
                            break;

                        case 2:
                            assignRegister(2, int.Parse(command[1]));
                            break;

                        case 3:
                            assignRegister(3, int.Parse(command[1]));
                            break;

                        case 4:
                            assignRegister(4, int.Parse(command[1]));
                            break;

                        case 5:
                            assignRegister(5, int.Parse(command[1]));
                            break;

                        case 6:
                            assignRegister(6, int.Parse(command[1]));
                            break;

                        case 7:
                            assignRegister(7, int.Parse(command[1]));
                            break;

                        case 8:
                            assignRegister(8, int.Parse(command[1]));
                            break;

                        case 9:
                            assignRegister(9, int.Parse(command[1]));
                            break;

                        case 10:
                            assignRegister(10, int.Parse(command[1]));
                            break;

                        case 11:
                            assignRegister(11, int.Parse(command[1]));
                            break;

                        case 12:
                            assignRegister(12, int.Parse(command[1]));
                            break;

                        case 13:
                            assignRegister(13, int.Parse(command[1]));
                            break;

                        case 14:
                            assignRegister(14, int.Parse(command[1]));
                            break;

                        case 15:
                            assignRegister(15, int.Parse(command[1]));
                            break;
                        }
                    }
                    else
                    {     // if the register number is greater than 10, and therefore has two digits to it's number
                        switch (int.Parse((command[2][2].ToString())))
                        {
                        case 0:
                            assignRegister(10, int.Parse(command[1]));
                            break;

                        case 1:
                            assignRegister(11, int.Parse(command[1]));
                            break;

                        case 2:
                            assignRegister(12, int.Parse(command[1]));
                            break;

                        case 3:
                            assignRegister(13, int.Parse(command[1]));
                            break;

                        case 4:
                            assignRegister(14, int.Parse(command[1]));
                            break;

                        case 5:
                            assignRegister(15, int.Parse(command[1]));
                            break;
                        }
                    }
                }
                else
                {
                    //define destination register number:
                    string destinationRegisterNoStr = command[2].ToString().Substring(1);     //remove r
                    int    destinationRegisterNo    = int.Parse(destinationRegisterNoStr);
                    switch (command[1].ToString())
                    {
                    case "R0":
                        assignRegister(destinationRegisterNo, R0);
                        break;

                    case "R1":
                        assignRegister(destinationRegisterNo, R1);
                        break;

                    case "R2":
                        assignRegister(destinationRegisterNo, R2);
                        break;

                    case "R3":
                        assignRegister(destinationRegisterNo, R3);
                        break;

                    case "R4":
                        assignRegister(destinationRegisterNo, R4);
                        break;

                    case "R5":
                        assignRegister(destinationRegisterNo, R5);
                        break;

                    case "R6":
                        assignRegister(destinationRegisterNo, R6);
                        break;

                    case "R7":
                        assignRegister(destinationRegisterNo, R7);
                        break;

                    case "R8":
                        assignRegister(destinationRegisterNo, R8);
                        break;

                    case "R9":
                        assignRegister(destinationRegisterNo, R9);
                        break;

                    case "R10":
                        assignRegister(destinationRegisterNo, R10);
                        break;

                    case "R11":
                        assignRegister(destinationRegisterNo, R11);
                        break;

                    case "R12":
                        assignRegister(destinationRegisterNo, R12);
                        break;

                    case "R13":
                        assignRegister(destinationRegisterNo, R13);
                        break;

                    case "R14":
                        assignRegister(destinationRegisterNo, R14);
                        break;

                    case "R15":
                        assignRegister(destinationRegisterNo, R15);
                        break;
                    }
                }



                break;
            }
            writesheet.text += "\n" + text;
        }

        if (commandSuccessful && displayMsg)
        {
            console.text += "\n" + text + " ~ completed";
        }
        else if (!displayMsg)
        {
        }
        else
        {
            console.text += "\n" + text + " ~ command rejected";
        }
    }