コード例 #1
0
        private void InitdataGridViewParam(int fileNo, int recNo, short clientNo)
        {
            int ret = -1;

            ret = CollectShare.Instance().HNC_ParamanGetSubClassProp(fileNo, (Byte)ParaSubClassProp.SUBCLASS_ROWNUM, ref rowNum, clientNo);
            if (rowNum < 0)
            {
                return;
            }

            ret = CollectShare.Instance().HNC_ParamanRewriteSubClass(fileNo, recNo, clientNo);
            if (ret < 0)
            {
                return;
            }
            if (rowNum < dataGridViewParam.RowCount)//删除多余的行
            {
                for (int index = dataGridViewParam.RowCount - 1; index >= rowNum; index--)
                {
                    dataGridViewParam.Rows.RemoveAt(index);
                }
            }
            for (int index = 0; index < dataGridViewParam.RowCount; index++)
            {
                dataGridViewParam.Rows[index].Cells[0].Value = null;
            }
            timerUpdataShow.Enabled = true;
        }
コード例 #2
0
        private int AddParamanItemFrmNet(short clientNo)
        {
            int    fileNum  = HNCDATADEF.PARAMAN_MAX_FILE_LIB;
            string fileName = "";
            int    ret      = 0;

            for (int i = 0; i < fileNum; i++)
            {
                ret = CollectShare.Instance().HNC_ParamanGetFileName(i, ref fileName, clientNo);
                if (ret < 0)
                {
                    break;
                }

                TreeNode rootNode = new TreeNode(fileName);
                treeViewParaman.Nodes.Add(rootNode);

                int recNum = -1;
                ret = CollectShare.Instance().HNC_ParamanGetSubClassProp(i, (Byte)ParaSubClassProp.SUBCLASS_NUM, ref recNum, clientNo);

                if (recNum < 0)
                {
                    ret = recNum;
                    break;
                }
                else if (recNum > 1)
                {
                    string recName = "";
                    ret = CollectShare.Instance().HNC_ParamanGetSubClassProp(i, (Byte)ParaSubClassProp.SUBCLASS_NAME, ref recName, clientNo);
                    if (ret < 0)
                    {
                        break;
                    }

                    for (int j = 0; j < recNum; j++)
                    {
                        rootNode.Nodes.Add(new TreeNode(recName + j.ToString()));
                    }
                }
            }
            return(ret);
        }
コード例 #3
0
        public void InitParamanTreeView(short clientNo)
        {
            this.ClientNo = clientNo;
            if (!CollectShare.Instance().HNC_NetIsConnect(clientNo))
            {
                return;
            }
            treeViewParaman.Nodes.Clear();

            //short clientNo = 0;
            if (CollectShare.Instance().HNC_NetIsConnect(clientNo))
            {
                treeViewParaman.Nodes.Add(new TreeNode(STR_NO_CONNECTION));
            }
            else
            {
                int ret = AddParamanItemFrmNet(clientNo);
                if (ret < 0)
                {
                    MessageBox.Show("网络读取参数结构错误!");
                }
            }
            UpdatalistViewParm();
        }
コード例 #4
0
        private int GetParItemText(int fileNo, int recNo, int row, short clientNo, string[] strPar)
        {
            Int16 dupNum = 0;
            Int16 dupNo  = 0;
            Int32 index  = -1;
            Int32 parmID = -1;
            int   ret    = -1;

            ret = CollectShare.Instance().HNC_ParamanTransRow2Index(fileNo, recNo, row, ref index, ref dupNum, ref dupNo, clientNo);
            if (index < 0)
            {
                return(-1);
            }

            //获取生效方式
            Int32 actType = -1;

            ret = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_ACT, ref actType, clientNo);
            if (actType < 0)
            {
                return(-1);
            }

            switch (actType)
            {
            //case (sbyte)CDataDef.PAR_ACT_TYPE.PARA_ACT_SAVE:
            case (sbyte)ParaActType.PARA_ACT_SAVE:
                strPar[3] = STR_ACT[0];
                break;

            case (sbyte)ParaActType.PARA_ACT_NOW:
                strPar[3] = STR_ACT[1];
                break;

            case (sbyte)ParaActType.PARA_ACT_RST:
                strPar[3] = STR_ACT[2];
                break;

            case (sbyte)ParaActType.PARA_ACT_PWR:
                strPar[3] = STR_ACT[3];
                break;
            }

            //获取参数号
            ret = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_ID, ref parmID, clientNo);
            if (ret < 0)
            {
                return(-1);
            }
            strPar[0] = parmID.ToString("D6");

            //获取参数名称
            ret = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_NAME, ref strPar[1], clientNo);
            if (ret < 0)
            {
                return(-1);
            }

            //获取参数储存类型
            Int32 storeType = -1;

            ret = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_STORE, ref storeType, clientNo);
            if (storeType < 0)
            {
                return(-1);
            }

            //获取参数值、默认值、最小值和最大值
            int    iVal = 0;
            double dVal = 0;

            //const int DFT = 1;
            //const int MIN = 2;
            //const int MAX = 3;
            switch (storeType)
            {
            case (sbyte)HNCDATATYPE.DTYPE_BOOL:
            case (sbyte)HNCDATATYPE.DTYPE_UINT:
            case (sbyte)HNCDATATYPE.DTYPE_INT:
                ret = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_VALUE, ref iVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[2] = iVal.ToString();
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_DFVALUE, ref iVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[4] = iVal.ToString();
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_MINVALUE, ref iVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[5] = iVal.ToString();
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_MAXVALUE, ref iVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[6] = iVal.ToString();
                break;

            case (sbyte)HNCDATATYPE.DTYPE_FLOAT:
                ret = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_VALUE, ref dVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[2] = dVal.ToString("F6");
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_DFVALUE, ref dVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[4] = dVal.ToString("F6");
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_MINVALUE, ref dVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[5] = dVal.ToString("F6");
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_MAXVALUE, ref dVal, clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[6] = dVal.ToString("F6");
                break;

            case (sbyte)HNCDATATYPE.DTYPE_STRING:
                ret = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_VALUE, ref strPar[2], clientNo);
                if (ret < 0)
                {
                    break;
                }
                strPar[4] = "N/A";
                strPar[5] = "N/A";
                strPar[6] = "N/A";
                break;

            case (sbyte)HNCDATATYPE.DTYPE_HEX4:
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_VALUE, ref iVal, clientNo);
                strPar[2] = "0x" + iVal.ToString("X2");
                strPar[4] = "N/A";
                strPar[5] = "N/A";
                strPar[6] = "N/A";
                break;

            case (sbyte)HNCDATATYPE.DTYPE_BYTE:
                sbyte[] araayBt = new sbyte[HNCDATATYPE.PARAM_STR_LEN];
                ret       = CollectShare.Instance().HNC_ParamanGetParaProp(fileNo, recNo, index, (Byte)ParaPropType.PARA_PROP_VALUE, ref actType, clientNo);
                strPar[2] = GetStringFrmByte(araayBt);
                strPar[4] = "N/A";
                strPar[5] = "N/A";
                strPar[6] = "N/A";
                break;

            default:
                strPar[2] = "0";
                break;
            }
            if (ret < 0)
            {
                return(-1);
            }

            return(0);
        }
コード例 #5
0
ファイル: RfidForm.cs プロジェクト: 0000duck/software
 private void button2_Click(object sender, EventArgs e)
 {
     CollectShare.Instance().HNC_RegSetBit((Int32)HNCAPI.HncRegType.REG_TYPE_R, 22, 0, Collector.CollectHNCPLC.m_clientNo);
 }