Code: Select all
DigitalInput[] digital_inputs = new DigitalInput[INPUTS_COUNT] ;
DigitalOutput[] digital_outputs = new DigitalOutput[OUTPUTS_COUNT];
private void InputsInit(int inputs, int type)
{
int i;
try
{
for (i = 0; i < inputs; i++)
{
digital_inputs[i] = new DigitalInput
{
DeviceSerialNumber = type,
Channel = i
};
digital_inputs[i].StateChange += DigitalInput_StateChange;
}
for (i = 0; i < inputs; i++)
{
digital_inputs[i].Open(WAIT_ATTACH_MS);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
device_connected = false;
}
}
private void OutputsInit(int outputs, int type)
{
int i;
try
{
for (i = 0; i < outputs; i++)
{
digital_outputs[i] = new DigitalOutput
{
DeviceSerialNumber = type,
Channel = i
};
}
for (i = 0; i < outputs; i++)
{
digital_outputs[i].Open(WAIT_ATTACH_MS);
}
device_connected = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
device_connected = false;
}
}
private void CardInit(int card_type)
{
if (card_type == CARD_TYPE_0_0_4)
{
io_count = 4;
dev_ser_number = 520535;
OutputsInit(io_count, dev_ser_number);
}
else if (card_type == CARD_TYPE_0_16_16)
{
io_count = 16;
dev_ser_number = 546353;
InputsInit(io_count, dev_ser_number);
OutputsInit(io_count, dev_ser_number);
}
}
Code: Select all
private void CheckedChanged(object sender, EventArgs e)
{
CheckBox outputChk = (CheckBox)sender;
int outputIndex = int.Parse((string)outputChk.Tag);
if (outputIndex < io_count)
digital_outputs[outputIndex].State = outputChk.Checked;
}
Code: Select all
DigitalInput[] digital_inputs = new DigitalInput[INPUTS_COUNT] ;
DigitalOutput[] digital_outputs = new DigitalOutput[OUTPUTS_COUNT];
I want to switch on some outputs in one exe and switch it off in another.