Example #1
0
        public static string _getFile_MD5(string vFn)
        {
            if (!File.Exists(vFn))
            {
                return("   ");
            }
            try
            {
                FileStream _fs  = new FileStream(vFn, FileMode.Open);
                MD5        _md5 = new MD5CryptoServiceProvider();
                //MD5 _md5 = MD5.Create();
                byte[] _buf = _md5.ComputeHash(_fs);
                _fs.Close();

                StringBuilder _sb = new StringBuilder();
                for (int i = 0; i < _buf.Length; i++)
                {
                    _sb.Append(_buf[i].ToString("x2"));
                }
                return(F_TransCalc.doBytesToStr(_buf));
            }
            catch (Exception ex)
            {
                throw new Exception("_getFile_MD5() :" + ex.Message);
            }
        }
Example #2
0
        // 取值

        public static int _Get_Value_2(clsFaim3 _faim3, string strFld, ref string outStr)
        {
            string _Name = strFld.Replace("*", ""); // *strFld ==> _ls 有星号表明不是值,而是"变量名"

            outStr = "   ";
            int _bit  = -1;
            int _val_ = 0;

            if (string.IsNullOrEmpty(_Name))
            {
                _val_  = -999;
                outStr = _Name;
            }
            else if (_faim3.dict_DevFunction.ContainsKey(_Name))     // IO集变量2DI_0[_ls]
            {
                #region                                              // dict_DevFunction IO 口定义

                clsDevFunction _df = _faim3.dict_DevFunction[_Name]; //
                _bit = _df.devNo * _faim3.sect_iDev + _df.Index;     //
                if (_df.varName.ToUpper() == "BT_IN")
                {
                    _val_ = _faim3.Comm_Data.bt_in[0][_bit];
                }
                else if (_df.varName.ToUpper() == "BT_OUT")
                {
                    _val_ = _faim3.Comm_Data.bt_out[0][_bit];
                }
                #endregion
            }
            else if (_faim3._dim_dict.ContainsKey(_Name)) // 动态变量[_Name]
            {
                #region                                   // _dim_dict  动态变量


                if (_Name.ToUpper().StartsWith("&H"))
                {
                    _Name = _Name.ToUpper().Replace("&H", "");
                    _val_ = Convert.ToInt32(_Name, 16);
                }
                else if (_Name.ToUpper().StartsWith("0X"))
                {
                    _Name = _Name.ToUpper().Replace("0X", "");
                    _val_ = Convert.ToInt32(_Name, 16);
                }
                //else if (_Name.StartsWith("0"))
                //{
                //    _val_ = Convert.ToInt32(_Name, 2);
                //}
                else if (F_TransCalc.IsNumeric(_Name))
                {
                    _val_ = Convert.ToInt32(_Name);
                }
                else
                {
                    _bit   = _faim3._dim_dict[_Name];// 自定义名为下标, 分配地址, 寻址
                    _val_  = _faim3._dim[_bit];
                    outStr = _Name;
                }
                #endregion
            }
            else if (_Name.ToUpper().StartsWith("_FAIM3") ||// 大数据  _faim3 || clsfraim3
                     _Name.ToUpper().StartsWith("CLSFAIM3"))
            {
                #region // _FAIM3 大数据

                _bit   = 1;
                _val_  = Convert.ToInt32(F_TransCalc.doGetValue_byName(_faim3, _Name));
                outStr = _Name;
                #endregion
            }
            else
            {
                #region // 常数
                if (_Name.ToUpper().StartsWith("-"))
                {
                    _val_  = -999;
                    outStr = _Name;
                }
                else if (_Name.ToUpper().StartsWith("&H"))
                {
                    _Name = _Name.ToUpper().Replace("&H", "");
                    _val_ = Convert.ToInt32(_Name, 16);
                }
                else if (_Name.ToUpper().StartsWith("0X"))
                {
                    _Name = _Name.ToUpper().Replace("0X", "");
                    _val_ = Convert.ToInt32(_Name, 16);
                }
                else if (_Name.StartsWith("0"))
                {
                    _val_ = Convert.ToInt32(_Name, 2);
                }
                else if (F_TransCalc.IsNumeric(_Name))
                {
                    _val_ = Convert.ToInt32(_Name);
                }
                else
                {
                    _val_  = -999;
                    outStr = _Name;
                }
                #endregion
            }
            return(_val_);
        }