H
Hoop
Hi,
I have a project where I have to store what we call modules. To get
the project going I have been using an array, however this will not be
the best way as the items that will be stored are dynamic, might or
might not be an instance of one.
What I have is a abstract base class where I will create instances of
as needed, here is the base class.
public abstract class BaseModule
{
//circuit names
private List<string> circuitNameList = new List<string>();
//IO point numbers
private List<string> ioPointNumbersList = new List<string>();
//circuit numbers
private List<string> circuitNumberList = new List<string>();
//circuit type, as in Input or Output
private List<string> circuitTypeList = new List<string>();
//point type, as in Digital, ground, etc.
private List<string> ioPointTypeList = new List<string>();
//access to the circuit name list
public List<string> CircuitNames
{
get { return circuitNameList; }
set { circuitNameList = value; }
}
//access to the io point numbers list
public List<string> IOPointNumbers
{
get { return ioPointNumbersList; }
set { ioPointNumbersList = value; }
}
//access to the circuit numbers list
public List<string> CircuitNumber
{
get { return circuitNumberList; }
set { circuitNumberList = value; }
}
//access to the circuit type list
public List<string> CircuitType
{
get { return circuitTypeList; }
set { circuitTypeList = value; }
}
//access to the iopoint type list
public List<string> IOPointType
{
get { return ioPointTypeList; }
set { ioPointTypeList = value; }
}
//how many IO's
//use circuit name count
public int RecordCount()
{
return circuitNameList.Count;
}
}
For one series of modules that I am testing there can be 0 - 16 of
these, currently I am using an array like so,
public TestModules[] testModule = new TestModules[16];
These testModules inherit from the above base class as is for now.
Problem here is that there might not be any of these modules, and if
there are some the index will not nessasarily be in order, could be
module 0, 6, 9, and order. The index ID's the module. Each module will
have 16 pieces of the data listed in the baseclass.
I was thinking of createing a list for these,
private List<TestModules> testModuleslist = new List<TestModules>();
When I add a piece of data, each single added piece of data moves up
the list, like so
aMod.CircuitNames.Add(this.circuitNameTxtBox.Text);
aMod.IOPointNumbers.Add(this.IOPointNumberTxtBox.Text);
aMod.CircuitNumber.Add(this.circuitNumberTxtBox.Text);
aMod.CircuitType.Add(this.cmbCircuitType.Text);
aMod.IOPointType.Add(this.cmbIOPointType.Text);
I wind up with the data added to the list in the above order, but I
cannot correctly id to what module it belongs
I am trying to get something like,
aMod[1]CircuitNames[1].Add(this.circuitNameTxtBox.Text);
aMod[1].IOPointNumbers[1].Add(this.IOPointNumberTxtBox.Text);
aMod[1].CircuitNumber[1].Add(this.circuitNumberTxtBox.Text);
aMod[1].CircuitType[1].Add(this.cmbCircuitType.Text);
aMod[1].IOPointType[1].Add(this.cmbIOPointType.Text);
aMod[1]CircuitNames[2].Add(this.circuitNameTxtBox.Text);
aMod[1].IOPointNumbers[2].Add(this.IOPointNumberTxtBox.Text);
aMod[1].CircuitNumber[2].Add(this.circuitNumberTxtBox.Text);
aMod[1].CircuitType[2].Add(this.cmbCircuitType.Text);
aMod[1].IOPointType[2].Add(this.cmbIOPointType.Text);
the above could go on to where the second idex gets up 15, this would
be one module.
the first index, aMod[1], also could go up to 16, aMod[2], aMod[3],
etc, with 16 pieces of the point data
for each mod[].
Then when I access the data I can find the specific points.
I am not certian if I can even achieve this with a List<>.
Hope I posted enough code and description for a good example.
Any storage suggesstions would be appreciated.
Thanks
Jeff
I have a project where I have to store what we call modules. To get
the project going I have been using an array, however this will not be
the best way as the items that will be stored are dynamic, might or
might not be an instance of one.
What I have is a abstract base class where I will create instances of
as needed, here is the base class.
public abstract class BaseModule
{
//circuit names
private List<string> circuitNameList = new List<string>();
//IO point numbers
private List<string> ioPointNumbersList = new List<string>();
//circuit numbers
private List<string> circuitNumberList = new List<string>();
//circuit type, as in Input or Output
private List<string> circuitTypeList = new List<string>();
//point type, as in Digital, ground, etc.
private List<string> ioPointTypeList = new List<string>();
//access to the circuit name list
public List<string> CircuitNames
{
get { return circuitNameList; }
set { circuitNameList = value; }
}
//access to the io point numbers list
public List<string> IOPointNumbers
{
get { return ioPointNumbersList; }
set { ioPointNumbersList = value; }
}
//access to the circuit numbers list
public List<string> CircuitNumber
{
get { return circuitNumberList; }
set { circuitNumberList = value; }
}
//access to the circuit type list
public List<string> CircuitType
{
get { return circuitTypeList; }
set { circuitTypeList = value; }
}
//access to the iopoint type list
public List<string> IOPointType
{
get { return ioPointTypeList; }
set { ioPointTypeList = value; }
}
//how many IO's
//use circuit name count
public int RecordCount()
{
return circuitNameList.Count;
}
}
For one series of modules that I am testing there can be 0 - 16 of
these, currently I am using an array like so,
public TestModules[] testModule = new TestModules[16];
These testModules inherit from the above base class as is for now.
Problem here is that there might not be any of these modules, and if
there are some the index will not nessasarily be in order, could be
module 0, 6, 9, and order. The index ID's the module. Each module will
have 16 pieces of the data listed in the baseclass.
I was thinking of createing a list for these,
private List<TestModules> testModuleslist = new List<TestModules>();
When I add a piece of data, each single added piece of data moves up
the list, like so
aMod.CircuitNames.Add(this.circuitNameTxtBox.Text);
aMod.IOPointNumbers.Add(this.IOPointNumberTxtBox.Text);
aMod.CircuitNumber.Add(this.circuitNumberTxtBox.Text);
aMod.CircuitType.Add(this.cmbCircuitType.Text);
aMod.IOPointType.Add(this.cmbIOPointType.Text);
I wind up with the data added to the list in the above order, but I
cannot correctly id to what module it belongs
I am trying to get something like,
aMod[1]CircuitNames[1].Add(this.circuitNameTxtBox.Text);
aMod[1].IOPointNumbers[1].Add(this.IOPointNumberTxtBox.Text);
aMod[1].CircuitNumber[1].Add(this.circuitNumberTxtBox.Text);
aMod[1].CircuitType[1].Add(this.cmbCircuitType.Text);
aMod[1].IOPointType[1].Add(this.cmbIOPointType.Text);
aMod[1]CircuitNames[2].Add(this.circuitNameTxtBox.Text);
aMod[1].IOPointNumbers[2].Add(this.IOPointNumberTxtBox.Text);
aMod[1].CircuitNumber[2].Add(this.circuitNumberTxtBox.Text);
aMod[1].CircuitType[2].Add(this.cmbCircuitType.Text);
aMod[1].IOPointType[2].Add(this.cmbIOPointType.Text);
the above could go on to where the second idex gets up 15, this would
be one module.
the first index, aMod[1], also could go up to 16, aMod[2], aMod[3],
etc, with 16 pieces of the point data
for each mod[].
Then when I access the data I can find the specific points.
I am not certian if I can even achieve this with a List<>.
Hope I posted enough code and description for a good example.
Any storage suggesstions would be appreciated.
Thanks
Jeff