Esempio n. 1
0
 public void V1000SQLtoParam(DataRow p_dr, ref V1000_Param_Data p_Data)
 {
     p_Data.RegAddress = Convert.ToUInt16(p_dr[1].ToString());
     p_Data.ParamNum   = p_dr[2].ToString();
     p_Data.ParamName  = p_dr[3].ToString();
     p_Data.Multiplier = Convert.ToUInt16(p_dr[5].ToString());
     p_Data.NumBase    = Convert.ToByte(p_dr[6].ToString());
     p_Data.Units      = p_dr[7].ToString();
     p_Data.DefVal     = Convert.ToUInt16(p_dr[4].ToString());
 }
Esempio n. 2
0
        private void bwrkReadVFDDefs_DoWork(object sender, DoWorkEventArgs e)
        {
            int status = 0;
            V1000_ModbusRTU_Comm comm   = new V1000_ModbusRTU_Comm();
            ModbusRTUMsg         msg    = new ModbusRTUMsg(0x1F);
            ModbusRTUMaster      modbus = new ModbusRTUMaster();
            List <ushort>        tmp    = new List <ushort>();

            VFD_Vals.Clear();
            if (comm.OpenCommPort(ref spVFD) == 0x0001)
            {
                ProgressArgs.VFDRead_Total_Units = V1000_xlRead_List.Count;

                for (int i = 0; i < V1000_xlRead_List.Count; i++)
                {
                    ProgressArgs.VFDRead_Unit     = i;
                    ProgressArgs.VFDRead_Progress = (byte)(((float)i / ProgressArgs.VFDRead_Total_Units) * 100);
                    bwrkReadVFDDefs.ReportProgress(ProgressArgs.VFDRead_Progress);
                    if (bwrkReadVFDDefs.CancellationPending)
                    {
                        e.Cancel = true;
                        bwrkReadVFDDefs.ReportProgress(0);
                        return;
                    }

                    V1000_Param_Data data = new V1000_Param_Data();

                    msg.Clear();
                    msg = modbus.CreateMessage(msg.SlaveAddr, ModbusRTUMaster.ReadReg, Convert.ToUInt16(V1000_xlRead_List[i].RegAddress, 16), 1, tmp);

                    status = comm.DataTransfer(ref msg, ref spVFD);
                    if (status == 0x0001)
                    {
                        // extract pertinent VFD parameter information the Excel File
                        data.ParamNum   = V1000_xlRead_List[i].ParamNum;
                        data.ParamName  = V1000_xlRead_List[i].ParamName;
                        data.Multiplier = Convert.ToUInt16(V1000_xlRead_List[i].Multiplier);

                        // Supplement the Excel file information with actual response from the VFD
                        data.RegAddress = msg.StartReg;
                        data.ParamVal   = msg.Data[0];
                        data.DefVal     = msg.Data[0];

                        VFD_Vals.Add(data);
                    }
                }

                ProgressArgs.VFDRead_Progress = 100;
                ProgressArgs.VFDRead_Stat     = 0x02;
                e.Result = 0x02;
                comm.CloseCommPort(ref spVFD);
                bwrkReadVFDDefs.ReportProgress(100);
            }
        }
Esempio n. 3
0
        private bool GetParamList(DataRow p_Row, string p_Col, ref DataTable p_Tbl, ref List <V1000_Param_Data> p_List)
        {
            bool ret_val = false;

            string file     = p_Row[p_Col].ToString() + dbFileExt;
            string conn_str = OLEBaseStr + DataDir + file + OLEEndStr;

            // Get the table containing the list of parameters automatically modified by a
            // heavy-duty setting and fill  the the Param_HD_Mods list with all the values.
            if (SQLGetTable(conn_str, ref p_Tbl))
            {
                ret_val = true;

                p_List.Clear();
                foreach (DataRow dr in p_Tbl.Rows)
                {
                    V1000_Param_Data param = new V1000_Param_Data();
                    V1000SQLtoParam(dr, ref param);
                    p_List.Add(param);
                }
            }

            return(ret_val);
        }
Esempio n. 4
0
        private void bwrkLoadVFDDefs_DoWork(object sender, DoWorkEventArgs e)
        {
            xlApp      = new XL.Application();
            xlWorkbook = xlApp.Workbooks.Open("C:\\Users\\sferry\\source\\repos\\V1000_Param_Prog\\V1000_Param_Prog\\data\\Parameter Defaults.dat");
            //xlWorkbook = xlApp.Workbooks.Open("C:\\Users\\steve\\source\\repos\\V1000_Param_Prog\\V1000_Param_Prog\\data\\Parameter Defaults.dat");
            xlWorksheet = xlWorkbook.Sheets[1];
            xlRange     = xlWorksheet.UsedRange;

            V1000_xlRead_List.Clear();

            ProgressArgs.VFDLoad_Total_Units = xlRange.Rows.Count - 1;

            for (int i = 2; i <= xlRange.Rows.Count; i++)
            {
                if (bwrkLoadVFDDefs.CancellationPending)
                {
                    e.Cancel = true;
                    bwrkLoadVFDDefs.ReportProgress(0);
                    return;
                }

                V1000_Param_Data ParamData = new V1000_Param_Data();

                if (xlRange.Cells[i, 1] != null && xlRange.Cells[i, 1].Value2 != null)
                {
                    ParamData.RegAddress = Convert.ToUInt16(xlRange.Cells[i, 1].Value2);
                }
                else
                {
                    ParamData.RegAddress = 0;
                }

                if (xlRange.Cells[i, 2] != null && xlRange.Cells[i, 2].Value2 != null)
                {
                    ParamData.ParamNum = xlRange.Cells[i, 2].Value2.ToString();
                }
                else
                {
                    ParamData.ParamNum = "0";
                }

                if (xlRange.Cells[i, 3] != null && xlRange.Cells[i, 3].Value2 != null)
                {
                    ParamData.ParamName = xlRange.Cells[i, 3].Value2.ToString();
                }
                else
                {
                    ParamData.ParamName = "0";
                }

                if (xlRange.Cells[i, 4] != null && xlRange.Cells[i, 4].Value2 != null)
                {
                    ParamData.DefVal = Convert.ToUInt16(xlRange.Cells[i, 4].Value2);
                }
                else
                {
                    ParamData.DefVal = 0;
                }

                if (xlRange.Cells[i, 5] != null && xlRange.Cells[i, 5].Value2 != null)
                {
                    ParamData.Multiplier = Convert.ToUInt16(xlRange.Cells[i, 5].Value2);
                }
                else
                {
                    ParamData.Multiplier = 1;
                }

                if (xlRange.Cells[i, 6] != null && xlRange.Cells[i, 6].Value2 != null)
                {
                    ParamData.NumBase = Convert.ToByte(xlRange.Cells[i, 6].Value2);
                }
                else
                {
                    ParamData.NumBase = 10;
                }

                if (xlRange.Cells[i, 7] != null && xlRange.Cells[i, 7].Value2 != null)
                {
                    ParamData.Units = xlRange.Cells[i, 7].Value2.ToString();
                }
                else
                {
                    ParamData.Units = "";
                }

                // Create a string version for display purposes of the actual default paramater value
                if (ParamData.NumBase == 16)
                {
                    ParamData.DefValDisp = "0x" + ParamData.DefVal.ToString("X4");
                }
                else
                {
                    ParamData.DefValDisp = ((float)ParamData.DefVal / ParamData.Multiplier).ToString() + " " + ParamData.Units;
                }

                VFD_Vals.Add(ParamData);

                ProgressArgs.VFDLoad_Unit     = i - 2;
                ProgressArgs.VFDLoad_Progress = (byte)(((float)ProgressArgs.VFDLoad_Unit / ProgressArgs.VFDLoad_Total_Units) * 100);
                bwrkLoadVFDDefs.ReportProgress((int)(((float)i / (xlRange.Rows.Count - 1)) * 100));
            }

            ProgressArgs.VFDLoad_Unit = ProgressArgs.VFDLoad_Total_Units - 1;
            e.Result = 0x02;
            bwrkLoadVFDDefs.ReportProgress(100);
        }