public override bool LoadParam()
        {
            string fileName = $@"{m_strDir}param.ini";

            if (!System.IO.Directory.Exists(m_strDir))
            {
                System.IO.Directory.CreateDirectory(m_strDir);
                SaveParam();
            }

            m_ExposureTime = IniTool.GetInt(fileName, "camera", "exposure", 1000);

            return(true);
        }
예제 #2
0
        private static void InitConfig()
        {
            //通讯接受 Tx
            R.Tx.Port = IniTool.GetInt(R.Files.Settings, "Tx", "Port", 52830);
            IniTool.Set(R.Files.Settings, "Tx", "Port", R.Tx.Port);

            R.Tx.ConnectKey = IniTool.GetString(R.Files.Settings, "Tx", "ConnectKey", R.Tx.ConnectKey);
            IniTool.Set(R.Files.Settings, "Tx", "ConnectKey", R.Tx.ConnectKey);

            //通讯转发 TxConvert
            R.TxConvert.IP = IniTool.GetString(R.Files.Settings, "TxConvert", "IP", "vaselee.com");
            IniTool.Set(R.Files.Settings, "TxConvert", "IP", R.TxConvert.IP);

            R.TxConvert.Port = IniTool.GetInt(R.Files.Settings, "TxConvert", "Port", 0);
            IniTool.Set(R.Files.Settings, "TxConvert", "Port", R.TxConvert.Port);

            R.TxConvert.ConnectKey = IniTool.GetString(R.Files.Settings, "TxConvert", "ConnectKey", R.TxConvert.ConnectKey);
            IniTool.Set(R.Files.Settings, "TxConvert", "ConnectKey", R.TxConvert.ConnectKey);
        }
예제 #3
0
 private void BTConnect_Click(object sender, EventArgs e)
 {
     if (RBLocal.Checked)
     {
         int port = IniTool.GetInt(R.Files.Settings, "Tx", "TcppPort", 0);
         if (port > 0)
         {
             Connect("127.0.0.1", port);
             Close();
         }
     }
     else if (RBRemote.Checked)
     {
         if (Str.Ok(TBIP.Text, TBPort.Text) && int.TryParse(TBPort.Text, out int port))
         {
             Connect(TBIP.Text, port);
             Close();
         }
     }
 }
예제 #4
0
        //[Command]
        //IP=127.0.0.1
        //Port=8001
        //Type=40002000
        //Data={"Item1":"127.0.0.1","Item2":8001}

        public static void Start()
        {
            Task.Factory.StartNew(() =>
            {
                while (!R.MainUI.IsDisposed)
                {
                    if (Ls.Ok(R.Tx.Hosts))
                    {
                        List <string> cmd_files = FileTool.GetAllFile(R.Paths.Command, new[] { "*.cmd.ini" });
                        string tuple_string     = Json.Object2String(new Tuple <string, int>("abc", 123));
                        if (Ls.Ok(cmd_files))
                        {
                            foreach (var file in cmd_files)
                            {
                                string ip   = IniTool.GetString(file, "Command", "IP", "");
                                int port    = IniTool.GetInt(file, "Command", "Port", 0);
                                int type    = IniTool.GetInt(file, "Command", "Type", 0);
                                string data = IniTool.GetString(file, "Command", "Data", "");

                                if (Str.Ok(ip) && type > 0)
                                {
                                    List <string> hosts = TxHostMapTool.GetHost($"{ip}");
                                    if (Ls.Ok(hosts))
                                    {
                                        foreach (var host in hosts)
                                        {
                                            Tuple <string, int> info = new Tuple <string, int>(ip, port);
                                            string ss = Json.Object2String(info);
                                            R.Tx.TcppServer.Write(host, type, Json.Object2Byte(ss));
                                        }
                                    }
                                }
                                R.Log.I($"处理指令:{type},IP:{ip},Port:{port},Data:{data}");
                                FileTool.Delete(file);
                            }
                        }
                    }
                    Sleep.S(10);
                }
            });
        }
예제 #5
0
 private void ConnectLocalByProcess()
 {
     try
     {
         Process[] process = Process.GetProcessesByName("USBManager.Service");
         if (Ls.Ok(process))
         {
             string file = process[0].MainModule.FileName;
             if (File.Exists(file))
             {
                 string path     = DirTool.Parent(file);
                 string set_file = DirTool.Combine(path, "USBManagerServiceSettings.ini");
                 int    port     = IniTool.GetInt(set_file, "Tx", "TcppPort", 0);
                 if (port > 0)
                 {
                     Connect("127.0.0.1", port);
                     Close();
                 }
             }
         }
     }
     catch { }
 }
예제 #6
0
        /// <summary>
        /// 初始化Ini配置信息
        /// </summary>
        static void InitIni()
        {
            DirTool.Create(R.Paths.Settings);
            DirTool.Create(R.Paths.Projects);
            DirTool.Create(R.Paths.DefaultPublishStorage);
            DirTool.Create(R.Paths.DefaultNewStorage);

            R.Paths.PublishStorage = IniTool.GetString(R.Files.Settings, "Paths", "PublishStorage", R.Paths.DefaultPublishStorage);
            if (string.IsNullOrWhiteSpace(R.Paths.PublishStorage))
            {
                R.Paths.PublishStorage = R.Paths.DefaultPublishStorage;
            }

            R.Paths.NewStorage = IniTool.GetString(R.Files.Settings, "Paths", "NewStorage", R.Paths.DefaultNewStorage);
            if (string.IsNullOrWhiteSpace(R.Paths.NewStorage))
            {
                R.Paths.NewStorage = R.Paths.DefaultNewStorage;
            }

            R.Tx.IP                  = IniTool.GetString(R.Files.Settings, "Console", "IP", "");
            R.Tx.Port                = IniTool.GetInt(R.Files.Settings, "Console", "Port", 0);
            R.Tx.LocalIP             = IniTool.GetString(R.Files.Settings, "Local", "IP", "");
            R.Tx.LocalName           = IniTool.GetString(R.Files.Settings, "Local", "Name", "");
            R.IsAutoDeleteExpiredLog = IniTool.GetBool(R.Files.Settings, "Settings", "AutoDeleteExpiredLog", false);
            R.AppID                  = IniTool.GetString(R.Files.Settings, "App", "ID", "");

            if (!Str.Ok(R.AppID))
            {
                R.AppID = GuidTool.Short();
                IniTool.Set(R.Files.Settings, "App", "ID", R.AppID);
            }

            if (!File.Exists(R.Files.NewStorageReadme))
            {
                TxtTool.Create(R.Files.NewStorageReadme, R.NewStorageReadmeTxt);
            }
        }
        /// <summary>
        /// 加载参数
        /// </summary>
        /// <returns></returns>
        public override bool LoadParam()
        {
            string fileName = $@"{m_strDir}param.ini";

            if (!System.IO.Directory.Exists(m_strDir))
            {
                System.IO.Directory.CreateDirectory(m_strDir);
                SaveParam();
            }

            m_ExposureTime = IniTool.GetInt(fileName, "camera", "exposure", 1000);

            //if (System.IO.File.Exists($"{m_strDir}MeasureHandle.mea"))
            //{
            //    HOperatorSet.ReadMeasure($"{m_strDir}MeasureHandle.mea", out MeasureHandle);
            //}

            //if (System.IO.File.Exists($"{m_strDir}MeasureRect.hobj"))
            //{
            //    HOperatorSet.ReadObject(out MeasureRect, $"{m_strDir}MeasureRect.hobj");
            //}

            return(true);
        }