shao пре 2 дана
родитељ
комит
bb18ce9554
5 измењених фајлова са 567 додато и 4 уклоњено
  1. 2 2
      common/enum.go
  2. 77 0
      common/options.go
  3. 445 0
      config/options.toml
  4. 1 1
      rpc_idl
  5. 42 1
      service/config.go

+ 2 - 2
common/enum.go

@@ -34,7 +34,7 @@ func AllLanguages() []Lang {
 type Source string
 
 const (
-	SOURCE_ELECTRON Source = "ELectron"
+	SOURCE_ELECTRON Source = "Electron"
 	SOURCE_BROWSER  Source = "Browser"
 	SOURCE_ANDROID  Source = "Android"
 	SOURCE_DEV      Source = "Dev"
@@ -43,7 +43,7 @@ const (
 func (p Source) ToString() string {
 	switch p {
 	case SOURCE_ELECTRON:
-		return "ELectron"
+		return "Electron"
 	case SOURCE_BROWSER:
 		return "Browser"
 	case SOURCE_ANDROID:

+ 77 - 0
common/options.go

@@ -0,0 +1,77 @@
+package common
+
+import (
+	"github.com/pelletier/go-toml/v2"
+	"google.golang.org/protobuf/types/known/structpb"
+	"log/slog"
+	"os"
+)
+
+var Opts Options
+
+type StringValueEntry struct {
+	Text  string `toml:"text"`
+	Value string `toml:"value"`
+}
+
+func (se *StringValueEntry) Struct() *structpb.Struct {
+	return &structpb.Struct{
+		Fields: map[string]*structpb.Value{
+			"text":  structpb.NewStringValue(se.Text),
+			"value": structpb.NewStringValue(se.Value),
+		},
+	}
+}
+
+type Float64ValueEntry struct {
+	Text  string  `toml:"text"`
+	Value float64 `toml:"value"`
+}
+
+func (ie *Float64ValueEntry) Struct() *structpb.Struct {
+	return &structpb.Struct{
+		Fields: map[string]*structpb.Value{
+			"text":  structpb.NewStringValue(ie.Text),
+			"value": structpb.NewNumberValue(ie.Value),
+		},
+	}
+}
+
+type AprCboOptions struct {
+	AECFiled         []StringValueEntry  `toml:"aec_filed"`
+	AECFilm          []Float64ValueEntry `toml:"aec_film"`
+	CompressionForce []Float64ValueEntry `toml:"compression_force"`
+	Dose             []Float64ValueEntry `toml:"dose"`
+	ExpCorrection    []Float64ValueEntry `toml:"exp_correction"`
+	ExposureMode     []Float64ValueEntry `toml:"exposure_mode"`
+	Focus            []Float64ValueEntry `toml:"focus"`
+	GridType         []Float64ValueEntry `toml:"grid_type"`
+	PatientSize      []StringValueEntry  `toml:"patient_size"`
+	TubeLoad         []Float64ValueEntry `toml:"tube_load"`
+	KV               []Float64ValueEntry `toml:"kv"`
+	Ma               []Float64ValueEntry `toml:"ma"`
+	Mas              []Float64ValueEntry `toml:"mas"`
+	Ms               []Float64ValueEntry `toml:"ms"`
+}
+
+type Options struct {
+	AprCbo AprCboOptions `toml:"apr_cbo"`
+}
+
+func init() {
+	configFilePath := "config/options.toml"
+
+	// 1. 读取 TOML 文件内容
+	data, err := os.ReadFile(configFilePath)
+	if err != nil {
+		slog.Error("Unable to parse options file", "file", configFilePath, "err", err)
+		panic(err)
+	}
+
+	err = toml.Unmarshal(data, &Opts)
+	if err != nil {
+		slog.Error("Error parsing TOML", "err", err)
+		panic(err)
+	}
+	slog.Info("Parsed options success")
+}

+ 445 - 0
config/options.toml

@@ -0,0 +1,445 @@
+apr_cbo.aec_filed = [
+    { text = "001", value = "001" },
+    { text = "010", value = "010" },
+    { text = "011", value = "011" },
+    { text = "100", value = "100" },
+    { text = "101", value = "101" },
+    { text = "110", value = "110" },
+    { text = "111", value = "111" },
+]
+
+apr_cbo.aec_film = [
+    { text = "0", value = 0 },
+    { text = "1", value = 1 },
+    { text = "2", value = 2 },
+]
+
+apr_cbo.compression_force = [
+    { text = "2",  value = 2 },
+    { text = "5",  value = 5 },
+    { text = "8",  value = 8 },
+    { text = "10", value = 10 },
+    { text = "15", value = 15 },
+]
+
+apr_cbo.dose = [
+    { text = "2",   value = 2 },
+    { text = "2.5", value = 2.5 },
+]
+
+apr_cbo.exp_correction = [
+    { text = "0", value = 0 },
+    { text = "1", value = 1 },
+]
+
+apr_cbo.exposure_mode = [
+    { text = "3 pt",  value = 0 },
+    { text = "2 pt",  value = 1 },
+    { text = "AEC",   value = 2 },
+    { text = "AEC2P", value = 3 },
+    { text = "1 pt",  value = 4 },
+    { text = "1pt with ext.exp", value = 5 },
+]
+
+apr_cbo.focus = [
+    { text = "Small Focus", value = 0 },
+    { text = "Large Focus", value = 1 },
+]
+
+apr_cbo.grid_type = [
+    { text = "0",   value = 0 },
+    { text = "150", value = 2 },
+    { text = "180", value = 3 },
+]
+
+apr_cbo.patient_size = [
+    { text = "Large",  value = "Large" },
+    { text = "Medium", value = "Medium" },
+    { text = "Small",  value = "Small" },
+    { text = "Custom", value = "Custom" },
+    { text = "All",    value = "All" },
+]
+
+apr_cbo.tube_load = [
+    { text = "80%",  value = 0.8 },
+    { text = "100%", value = 1 },
+]
+
+apr_cbo.kv = [
+    { text = "50",  value = 50 },
+    { text = "55",  value = 55 },
+    { text = "65",  value = 65 },
+    { text = "70",  value = 70 },
+    { text = "75",  value = 75 },
+    { text = "80",  value = 80 },
+    { text = "85",  value = 85 },
+    { text = "90",  value = 90 },
+    { text = "95",  value = 95 },
+    { text = "100", value = 100 },
+    { text = "110", value = 110 },
+    { text = "120", value = 120 }
+]
+
+apr_cbo.ma = [
+    { text = "10",   value = 10 },
+    { text = "12.5", value = 12.5 },
+    { text = "16",   value = 16 },
+    { text = "20",   value = 20 },
+    { text = "25",   value = 25 },
+    { text = "32",   value = 32 },
+    { text = "40",   value = 40 },
+    { text = "50",   value = 50 },
+    { text = "64",   value = 64 },
+    { text = "80",   value = 80 },
+    { text = "100",  value = 100 },
+    { text = "125",  value = 125 },
+    { text = "160",  value = 160 },
+    { text = "200",  value = 200 },
+    { text = "250",  value = 250 },
+    { text = "320",  value = 320 },
+    { text = "640",  value = 640 },
+    { text = "800",  value = 800 },
+    { text = "1000", value = 1000 }
+]
+
+apr_cbo.mas = [
+    { text = "0.5",  value = 0.5 },
+    { text = "1",    value = 1 },
+    { text = "1.6",  value = 1.6 },
+    { text = "2",    value = 2 },
+    { text = "2.4",  value = 2.4 },
+    { text = "2.5",  value = 2.5 },
+    { text = "3.2",  value = 3.2 },
+    { text = "4",    value = 4 },
+    { text = "5",    value = 5 },
+    { text = "6.3",  value = 6.3 },
+    { text = "6.4",  value = 6.4 },
+    { text = "8",    value = 8 },
+    { text = "10",   value = 10 },
+    { text = "12.5", value = 12.5 },
+    { text = "12.8", value = 12.8 },
+    { text = "16",   value = 16 },
+    { text = "20",   value = 20 },
+    { text = "25",   value = 25 },
+    { text = "25.6", value = 25.6 },
+    { text = "32",   value = 32 },
+    { text = "40",   value = 40 },
+    { text = "50",   value = 50 },
+    { text = "64",   value = 64 },
+    { text = "80",   value = 80 },
+    { text = "100",  value = 100 }
+]
+
+apr_cbo.ms = [
+    { text = "2.5",  value = 2.5 },
+    { text = "10",   value = 10 },
+    { text = "12",   value = 12 },
+    { text = "12.5", value = 12.5 },
+    { text = "16",   value = 16 },
+    { text = "20",   value = 20 },
+    { text = "25",   value = 25 },
+    { text = "32",   value = 32 },
+    { text = "40",   value = 40 },
+    { text = "50",   value = 50 },
+    { text = "64",   value = 64 },
+    { text = "80",   value = 80 },
+    { text = "100",  value = 100 },
+    { text = "160",  value = 160 },
+    { text = "200",  value = 200 },
+    { text = "250",  value = 250 },
+    { text = "320",  value = 320 },
+    { text = "640",  value = 640 },
+    { text = "800",  value = 800 },
+    { text = "1000", value = 1000 },
+    { text = "1250", value = 1250 },
+    { text = "1600", value = 1600 },
+    { text = "2500", value = 2500 },
+    { text = "3200", value = 3200 },
+]
+
+rad_images.auto_filming = [
+    { text = "Off", value = 0 },
+    { text = "When study is closed", value = 1 },
+]
+
+rad_images.auto_sending = [
+    { text = "Off", value = 0 },
+    { text = "When study is closed", value = 1 },
+]
+
+hardware_cbo.baud = [
+    { text = "75", value = 75 },
+    { text = "110", value = 110 },
+    { text = "134", value = 134 },
+    { text = "150", value = 150 },
+    { text = "300", value = 300 },
+    { text = "600", value = 600 },
+    { text = "1200", value = 1200 },
+    { text = "1800", value = 1800 },
+    { text = "2400", value = 2400 },
+    { text = "4800", value = 4800 },
+    { text = "7200", value = 7200 },
+    { text = "9600", value = 9600 },
+    { text = "14400", value = 14400 },
+    { text = "19200", value = 19200 },
+    { text = "38400", value = 38400 },
+    { text = "57600", value = 57600 },
+    { text = "115200", value = 115200 },
+    { text = "128000", value = 128000 }
+]
+
+hardware_cbo.byte_size = [
+    { text = "1",    value = 1 },
+    { text = "2",    value = 2 },
+    { text = "3",    value = 3 },
+    { text = "4",    value = 4 },
+    { text = "5",    value = 5 },
+]
+
+hardware_cbo.calibration_mode = [
+
+]
+
+hardware_cbo.collimator_type = [
+
+]
+
+hardware_cbo.control_level = [
+
+]
+
+hardware_cbo.default_rotation = [
+
+]
+
+hardware_cbo.detector_type = [
+
+]
+
+hardware_cbo.generator_type = [
+
+]
+
+hardware_cbo.mechanical_type = [
+
+]
+
+hardware_cbo.panel_exp_window_mode = [
+
+]
+
+hardware_cbo.panel_flag = [
+
+]
+
+hardware_cbo.panel_num = [
+
+]
+
+hardware_cbo.parity = [
+
+]
+
+hardware_cbo.read_filter = [
+
+]
+
+hardware_cbo.read_order = [
+
+]
+
+hardware_cbo.rotation_direction = [
+
+]
+
+hardware_cbo.save_raw_data_mode = [
+
+]
+
+hardware_cbo.stop_bits = [
+
+]
+
+hardware_cbo.stop_sign = [
+
+]
+
+hardware_cbo.syn_number = [
+
+]
+
+hardware_cbo.syn_type = [
+
+]
+
+hardware_cbo.xray_tube_vendor = [
+
+]
+
+image_display_item_types = [
+
+]
+
+img_proc.brightness_offset = [
+
+]
+
+img_proc.contrast_offset = [
+
+]
+
+lut_curve_type = [
+
+]
+
+labeling = [
+
+]
+
+length_unit = [
+
+]
+
+network_cbo.print_size = [
+
+]
+
+patient.category_option = [
+
+]
+
+patient.list_mode = [
+
+]
+
+patient.size_measure_style = [
+
+]
+
+patient.size_option = [
+
+]
+
+protocol_cbo.anatomic_region = [
+
+]
+
+protocol_cbo.collimator_center = [
+
+]
+
+protocol_cbo.collimator_filter = [
+
+]
+
+protocol_cbo.collimator_size = [
+
+]
+
+protocol_cbo.curve_type = [
+
+]
+
+protocol_cbo.film_orientation = [
+
+]
+
+protocol_cbo.film_size = [
+
+]
+
+protocol_cbo.image_laterality = [
+
+]
+
+protocol_cbo.image_rotate = [
+
+]
+
+protocol_cbo.label_position = [
+
+]
+
+protocol_cbo.label_style = [
+
+]
+
+protocol_cbo.orientation_column = [
+
+]
+
+protocol_cbo.print_format = [
+
+]
+
+protocol_cbo.stand_pos = [
+
+]
+
+protocol_cbo.user_level = [
+
+]
+
+protocol_cbo.view_position = [
+
+]
+
+protocol_cbo.work_station = [
+
+]
+
+protocol.procedure_view_mark_position = [
+
+]
+
+protocol.process_image_function = [
+
+]
+
+protocol.process_image_style = [
+
+]
+
+sex_full_option = [
+
+]
+
+sex_option = [
+
+]
+
+sex_neuterted_option = [
+
+]
+
+thickness_unit = [
+
+]
+
+weight_unit = [
+
+]
+
+workflow_cbo.crop_mode = [
+
+]
+
+workflow_cbo.lut_type = [
+
+]
+
+workflow_cbo.mark_zoom_mode = [
+
+]
+
+workflow_cbo.shutter_shape = [
+
+]
+
+workflow_cbo.tag_location = [
+
+]
+
+workflow_cbo.x_shutter_offset = [
+
+]

+ 1 - 1
rpc_idl

@@ -1 +1 @@
-Subproject commit fd1299aaac1e201fdd1a946f14143d93f04e4c14
+Subproject commit 095f02566cb5f696ff572ab67b21c5fe2437a33c

+ 42 - 1
service/config.go

@@ -2,7 +2,7 @@ package service
 
 import (
 	"context"
-	"resource-server/common"
+	"log/slog"
 )
 
 import (
@@ -11,6 +11,7 @@ import (
 )
 
 import (
+	"resource-server/common"
 	pb "resource-server/rpc_idl/dr_resource_pb"
 )
 
@@ -18,6 +19,46 @@ type ConfigServer struct {
 	pb.UnimplementedConfigServer
 }
 
+func (s *ConfigServer) GetOptions(_ context.Context, in *pb.OptionRequest) (*pb.OptionReply, error) {
+	slog.Info("Received GetOptions", "group", in.Group, "flag", in.Flag)
+	res := pb.OptionReply{}
+	switch in.GetGroup() {
+	case "apr_cbo":
+		switch in.GetFlag() {
+		case "aec_filed":
+			for _, v := range common.Opts.AprCbo.AECFiled {
+				res.Option = append(res.Option, v.Struct())
+			}
+		case "compression_force":
+			for _, v := range common.Opts.AprCbo.CompressionForce {
+				res.Option = append(res.Option, v.Struct())
+			}
+		case "exposure_mode":
+			for _, v := range common.Opts.AprCbo.ExposureMode {
+				res.Option = append(res.Option, v.Struct())
+			}
+		case "focus":
+			for _, v := range common.Opts.AprCbo.Focus {
+				res.Option = append(res.Option, v.Struct())
+			}
+		case "grid_types":
+			for _, v := range common.Opts.AprCbo.GridType {
+				res.Option = append(res.Option, v.Struct())
+			}
+		case "ma":
+			for _, v := range common.Opts.AprCbo.Ma {
+				res.Option = append(res.Option, v.Struct())
+			}
+		case "ms":
+			for _, v := range common.Opts.AprCbo.Ms {
+				res.Option = append(res.Option, v.Struct())
+			}
+		}
+	}
+	slog.Info("Received Option", "option", &res)
+	return &res, nil
+}
+
 func (s *ConfigServer) ConfigOptionList(ctx context.Context, in *pb.ConfigOptionListRequest) (*pb.ConfigOptionListReply, error) {
 	product, _, _ := common.GetHeader(ctx)
 	res := pb.ConfigOptionListReply{}