Access value from a class to use in a form.cs

  • Thread starter Thread starter skular
  • Start date Start date
S

skular

Guest
Hello guys,

I am trying to get access to a value that happens in another class and make use of that value to run a while loop in Form1.cs I have tried a few things but have no success and unsure how to use getters/setters in a situation like such. Ultimately I want to take that 750 value in CountValue and use it as the basis for my loop. Any help/direction would be greatly appreciated.

Here is my Class:

public class LabJackT4
{
#region Public Property
private double myCountValue = 0;
#endregion

#region .ctor
public LabJackT4()
{
//Set Default Value
//this.CountValue = 0;
}
#endregion

public double MyCount
{
get { return myCountValue; }
protected set { myCountValue = CountValue; }
}
protected

#region T4 Handle Definitions
int handle = 0;
int devType = 0;
int conType = 0;
int serNum = 0;
int ipAddr = 0;
int port = 0;
double voltage = 0;
public double CountValue = 0;
int maxBytesPerMB = 0;
string ipAddrStr = "";
#endregion

#region Public Methods
public void ConvertFromDAC()
{
try
{
LJM.OpenS("ANY", "ANY", "ANY", ref handle);
LJM.GetHandleInfo(handle, ref devType, ref conType, ref serNum, ref ipAddr, ref port, ref maxBytesPerMB);
LJM.NumberToIP(ipAddr, ref ipAddrStr);


}
catch (LJM.LJMException c)
{
showErrorMessage(c);
}
//if (devType == LJM.CONSTANTS.dtT4)
//{
string name = "AIN0";
LJM.eReadName(handle, name, ref voltage);
//CountValue = voltage / 0.0048828125;
CountValue = 750;
//}
}

Here is my form1.cs

private void AtgmButton_Click(object sender, EventArgs e)
{
AdjustLaser();
}

private void AdjustLaser()
{
//double intensity;
double mycount = labjackT4.myCountValue;
while (labjackT4.myCountValue < 2000)

labjackT4.ConvertFromDAC();
if (labjackT4.myCountValue > 500)
{
//intensity = 0.3;
//laser.setLdCurrSetpoint(intensity);
//Console.WriteLine("This button works for 3.3v!");
}
else
{
//intensity = 0.2;
//laser.setLdCurrSetpoint(intensity);
//Console.WriteLine("This button works for 2.0!");
}
Console.WriteLine("This button works!");
Console.ReadLine();
}

Continue reading...
 
Back
Top