# 韌體開發閉環流程 (FWAuto Flow)
direction: down

development_flow: "Development Flow" {
  style.fill: "#e8f5e8"
  style.stroke: "#4caf50"
  grid-columns: 2

  fwauto_container: "AI Assistant" {
    style.fill: "#f3e5f5"
    style.stroke: "#9c27b0"
    
    fwauto: "FWAuto" {
      icon: https://api.iconify.design/material-symbols/smart-toy.svg
      style.fill: "#f9fbe7"
    }
  }

  build_flow: "Build & Flash Flow" {
    style.fill: "#e3f2fd"
    style.stroke: "#2196f3"
    grid-columns: 1

    source_code: "Source Code" {
      icon: https://api.iconify.design/material-symbols/code.svg
      style.fill: "#fff9c4"
    }

    makefile_build: "Makefile (build)" {
      icon: https://api.iconify.design/material-symbols/build.svg
      style.fill: "#00ff00"
    }

    hex_bin: "HEX/BIN" {
      icon: https://api.iconify.design/material-symbols/memory.svg
      style.fill: "#f3e5f5"
    }

    makefile_flash: "Makefile (flash)" {
      icon: https://api.iconify.design/material-symbols/flash-on.svg
      style.fill: "#00ff00"
    }

    emu: "EMU" {
      icon: https://api.iconify.design/material-symbols/developer-board.svg
      style.fill: "#e3f2fd"
    }

    log: "Log" {
      icon: https://api.iconify.design/material-symbols/terminal.svg
      style.fill: "#e1f5fe"
    }
  }
}

external_tools: "Vender Tool" {
  style.fill: "#fbe9e7"
  style.stroke: "#ff5722"
  grid-columns: 1

  build_toolchain: "Build Toolchain" {
    style.fill: "#ff5722"
    grid-columns: 1
    
    gui_tools: "GUI Tools" {
      style.fill: "#ffcc80"
      
      linko_ide: "凌通 G+IDE" {
        icon: https://api.iconify.design/material-symbols/desktop-windows.svg
        style.fill: "#ffecb3"
      }
      
      stm32cube: "STM32CubeProgrammer" {
        icon: https://api.iconify.design/material-symbols/desktop-windows.svg
        style.fill: "#ffecb3"
      }
      
      keil: "Keil MDK" {
        icon: https://api.iconify.design/material-symbols/desktop-windows.svg
        style.fill: "#ffecb3"
      }
      
      iar: "IAR EWARM" {
        icon: https://api.iconify.design/material-symbols/desktop-windows.svg
        style.fill: "#ffecb3"
      }
    }
    
    cli_tools: "CLI Tools" {
      style.fill: "#ffcc80"
      
      gcc_cli: "GCC CLI" {
        icon: https://api.iconify.design/material-symbols/terminal.svg
        style.fill: "#ffecb3"
      }
      
      cmake: "CMake" {
        icon: https://api.iconify.design/material-symbols/build-circle.svg
        style.fill: "#ffecb3"
      }
      
      platformio: "PlatformIO" {
        icon: https://api.iconify.design/material-symbols/terminal.svg
        style.fill: "#ffecb3"
      }
    }
  }

  flash_tools: "Flash Software" {
    style.fill: "#ff5722"
    
    openocd: "OpenOCD" {
      icon: https://api.iconify.design/material-symbols/cable.svg
      style.fill: "#bbdefb"
    }
    
    jlink: "J-Link" {
      icon: https://api.iconify.design/material-symbols/cable.svg
      style.fill: "#bbdefb"
    }
    
    stlink: "ST-Link" {
      icon: https://api.iconify.design/material-symbols/cable.svg
      style.fill: "#bbdefb"
    }
    
    esptool: "esptool" {
      icon: https://api.iconify.design/material-symbols/cable.svg
      style.fill: "#bbdefb"
    }
  }
}

# 閉環流程連線
development_flow.build_flow.source_code -> development_flow.build_flow.makefile_build
development_flow.build_flow.makefile_build -> development_flow.build_flow.hex_bin
development_flow.build_flow.hex_bin -> development_flow.build_flow.makefile_flash
development_flow.build_flow.makefile_flash -> development_flow.build_flow.emu
development_flow.build_flow.emu -> development_flow.build_flow.log
development_flow.build_flow.log -> development_flow.fwauto_container.fwauto: "feedback" {
  style: {
    animated: true
  }
}
development_flow.fwauto_container.fwauto -> development_flow.build_flow.source_code: "modify" {
  style: {
    stroke-dash: 3
    animated: true
  }
}

# 廠商工具適配連線
development_flow.build_flow.makefile_build -> external_tools.build_toolchain: {
  style: {
    stroke: "#00ff00"
    stroke-width: 5
    animated: true
  }
}
  development_flow.build_flow.makefile_flash -> external_tools.flash_tools:  {
  style: {
    stroke: "#00ff00"
    stroke-width: 5
    animated: true
  }
}
