Example #1
0
 /////////////////////////////////////////////////////////////////////////////
 public void SetCfg(tagCFG cfg)                //重新写一遍就好了
 {
     // if (cfg.valid != DefineConstants.CFG_VALID)
     //     return;
     // char[] cmd=new char[DefineConstants.FRM_LEN_SC];
     // Array.Copy( m_cmd[(int)tagProCmd.PRO_CMD_SET_CFG], cmd,DefineConstants.DEFAULT_PRO_CMD_LEN);
     // cmd[1] = (char)DefineConstants.FRM_LEN_SC;
     // byte[] stctArr = StructToBytes(cfg);
     //// Array.Copy(cmd[5],StructToBytes(cfg), Marshal.SizeOf(new tagCFG()));
     // for(int i=0;i< Marshal.SizeOf(new tagCFG());i++)
     // {
     //     cmd[i + 5] =(char)stctArr[i];
     // }
     // if(DefineConstants.CHECKSUM_EN)     //校验和
     // {
     //     int j;
     //      char sum;
     //     for (sum = (char)0, j = 0; j < DefineConstants.FRM_LEN_SC - 2; j++)
     //     {
     //         sum += cmd[j];
     //     }
     //     cmd[DefineConstants.FRM_LEN_SC - 2] = sum;
     // }
     // else
     // {
     //     cmd[DefineConstants.FRM_LEN_SC - 2] = (char)DefineConstants.DEFAULT_SUM;
     // }
     // cmd[DefineConstants.FRM_LEN_SC - 1] = DefineConstants.FRM_TAIL;
     // string s = new string(cmd);
     // m_comm.Write(s);
 }
Example #2
0
 public ParamsSetings(demo hParent)
 {
     InitializeComponent();
     this.hParent = hParent;
     cFG          = hParent.cFG;
     cFG.errAdj   = 0.2f;
 }
Example #3
0
    public string PeakCvt(float val, int ch, ref float pPeakCvt)
    {
        string str;

        str      = "";
        pPeakCvt = 0.0f;

        tagCFG pCfg = m_deviceCfg;

        if (pCfg.Equals(null))
        {
            return(str);
        }
        //波峰值计算比例:
        //SOL: 传感器负荷(load):600kg	波峰值284mV   .            .  屏幕输出331Kg
        //My:  传感器负荷(load):60kg     波峰值2840mV  . AD值  3534 .  屏幕输出331Kg
        //(AD/4096)*load*p=force(kg)
        // =>  (3534/4096) * 60 * p = 331
        // => p = 1.94 (取2)
        // => AD *3.3 * 2 * load / 4096 => force
        float force = (float)(val * 6.6 * pCfg.ch[ch].load / 4096);    //KG

        switch (pCfg.unit)
        {
        case SYS_CFG_TYPE.UNIT_KG:
            pPeakCvt = force;
            str      = string.Format("% 5.0f Kg", pPeakCvt);
            break;

        case SYS_CFG_TYPE.UNIT_KN:
            pPeakCvt = force * DefineConstants.KG_KN;
            str      = string.Format("% 7.2f KN", pPeakCvt); //1 千克力 = 0.00980665 千牛顿
            break;

        case SYS_CFG_TYPE.UNIT_LB:
            pPeakCvt = force * DefineConstants.KG_LB;
            str      = string.Format("% 5.0f lb", pPeakCvt);     //1 千克力 = 2.2046 磅力
            break;

        default:
            pPeakCvt = force;
            str      = string.Format("% 5.0f Kg", pPeakCvt);
            break;
        }
        return(str);
    }
Example #4
0
 public demo()
 {
     InitializeComponent();
     cFG        = new tagCFG();
     cFG.errAdj = 11212f;
 }
Example #5
0
 public void Set(tagCFG cfg)
 {
     this.m_deviceCfg = cfg;
 }