Sie sind auf Seite 1von 10

#pragma once

namespace My11 {
using
using
using
using
using
using
using

namespace
namespace
namespace
namespace
namespace
namespace
namespace

System;
System::ComponentModel;
System::Collections;
System::Windows::Forms;
System::Data;
System::Drawing;
System::Runtime::InteropServices;

/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::CheckBox^ checkBox1;
private: System::Windows::Forms::CheckBox^ checkBox2;
private: System::Windows::Forms::CheckBox^ checkBox3;
private: System::Windows::Forms::CheckBox^ checkBox4;
private: System::Windows::Forms::CheckBox^ checkBox5;
private: System::Windows::Forms::CheckBox^ checkBox6;
private: System::Windows::Forms::CheckBox^ checkBox7;
private: System::Windows::Forms::CheckBox^ checkBox8;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Button^ button3;

private:
private:
private:
private:
private:
private:

System::Windows::Forms::Button^
System::Windows::Forms::Button^
System::Windows::Forms::Button^
System::Windows::Forms::Button^
System::Windows::Forms::Button^
System::Windows::Forms::Button^

button5;
button4;
button6;
button7;
button8;
button9;

protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button())
;
this->button2 = (gcnew System::Windows::Forms::Button())
;
this->checkBox1 = (gcnew System::Windows::Forms::CheckBo
x());
this->checkBox2 = (gcnew System::Windows::Forms::CheckBo
x());
this->checkBox3 = (gcnew System::Windows::Forms::CheckBo
x());
this->checkBox4 = (gcnew System::Windows::Forms::CheckBo
x());
this->checkBox5 = (gcnew System::Windows::Forms::CheckBo
x());
this->checkBox6 = (gcnew System::Windows::Forms::CheckBo
x());
this->checkBox7 = (gcnew System::Windows::Forms::CheckBo
x());
this->checkBox8 = (gcnew System::Windows::Forms::CheckBo
x());
this->textBox1 = (gcnew System::Windows::Forms::TextBox(
));
this->button3 = (gcnew System::Windows::Forms::Button())
;
this->button5 = (gcnew System::Windows::Forms::Button())
;
this->button4 = (gcnew System::Windows::Forms::Button())
;
this->button6 = (gcnew System::Windows::Forms::Button())
;
this->button7 = (gcnew System::Windows::Forms::Button())
;
this->button8 = (gcnew System::Windows::Forms::Button())
;
this->button9 = (gcnew System::Windows::Forms::Button())
;
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(47, 25)
;
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;

this->button1->Text = L"Povezi";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this,
&Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(47, 66)
;
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 1;
this->button2->Text = L"Odspoji";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this,
&Form1::button2_Click);
//
// checkBox1
//
this->checkBox1->AutoSize = true;
this->checkBox1->Location = System::Drawing::Point(228,
25);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(32, 17);
this->checkBox1->TabIndex = 2;
this->checkBox1->Text = L"1";
this->checkBox1->UseVisualStyleBackColor = true;
this->checkBox1->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox1_CheckedChanged);
//
// checkBox2
//
this->checkBox2->AutoSize = true;
this->checkBox2->Location = System::Drawing::Point(277,
25);
this->checkBox2->Name = L"checkBox2";
this->checkBox2->Size = System::Drawing::Size(32, 17);
this->checkBox2->TabIndex = 3;
this->checkBox2->Text = L"2";
this->checkBox2->UseVisualStyleBackColor = true;
this->checkBox2->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox2_CheckedChanged);
//
// checkBox3
//
this->checkBox3->AutoSize = true;
this->checkBox3->Location = System::Drawing::Point(325,
25);
this->checkBox3->Name = L"checkBox3";
this->checkBox3->Size = System::Drawing::Size(32, 17);
this->checkBox3->TabIndex = 4;
this->checkBox3->Text = L"3";
this->checkBox3->UseVisualStyleBackColor = true;
this->checkBox3->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox3_CheckedChanged);
//
// checkBox4
//
this->checkBox4->AutoSize = true;
this->checkBox4->Location = System::Drawing::Point(373,

25);
this->checkBox4->Name = L"checkBox4";
this->checkBox4->Size = System::Drawing::Size(32, 17);
this->checkBox4->TabIndex = 5;
this->checkBox4->Text = L"4";
this->checkBox4->UseVisualStyleBackColor = true;
this->checkBox4->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox4_CheckedChanged);
//
// checkBox5
//
this->checkBox5->AutoSize = true;
this->checkBox5->Location = System::Drawing::Point(420,
25);
this->checkBox5->Name = L"checkBox5";
this->checkBox5->Size = System::Drawing::Size(32, 17);
this->checkBox5->TabIndex = 6;
this->checkBox5->Text = L"5";
this->checkBox5->UseVisualStyleBackColor = true;
this->checkBox5->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox5_CheckedChanged);
//
// checkBox6
//
this->checkBox6->AutoSize = true;
this->checkBox6->Location = System::Drawing::Point(469,
25);
this->checkBox6->Name = L"checkBox6";
this->checkBox6->Size = System::Drawing::Size(32, 17);
this->checkBox6->TabIndex = 7;
this->checkBox6->Text = L"6";
this->checkBox6->UseVisualStyleBackColor = true;
this->checkBox6->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox6_CheckedChanged);
//
// checkBox7
//
this->checkBox7->AutoSize = true;
this->checkBox7->Location = System::Drawing::Point(518,
25);
this->checkBox7->Name = L"checkBox7";
this->checkBox7->Size = System::Drawing::Size(32, 17);
this->checkBox7->TabIndex = 8;
this->checkBox7->Text = L"7";
this->checkBox7->UseVisualStyleBackColor = true;
this->checkBox7->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox7_CheckedChanged);
//
// checkBox8
//
this->checkBox8->AutoSize = true;
this->checkBox8->Location = System::Drawing::Point(567,
25);
this->checkBox8->Name = L"checkBox8";
this->checkBox8->Size = System::Drawing::Size(32, 17);
this->checkBox8->TabIndex = 9;
this->checkBox8->Text = L"8";
this->checkBox8->UseVisualStyleBackColor = true;
this->checkBox8->CheckedChanged += gcnew System::EventHa
ndler(this, &Form1::checkBox8_CheckedChanged);

//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(228, 6
9);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(100, 20);
this->textBox1->TabIndex = 10;
this->textBox1->TextAlign = System::Windows::Forms::Hori
zontalAlignment::Center;
//
// button3
//
this->button3->Location = System::Drawing::Point(976, 40
9);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 23);
this->button3->TabIndex = 11;
this->button3->Text = L"Izlaz";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this,
&Form1::button3_Click);
//
// button5
//
this->button5->Location = System::Drawing::Point(47, 153
);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(75, 23);
this->button5->TabIndex = 15;
this->button5->Text = L"Neparni";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this,
&Form1::button5_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(47, 111
);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(75, 23);
this->button4->TabIndex = 16;
this->button4->Text = L"Parni";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this,
&Form1::button4_Click);
//
// button6
//
this->button6->Location = System::Drawing::Point(47, 203
);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(85, 23);
this->button6->TabIndex = 17;
this->button6->Text = L"Iskljui parne";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this,
&Form1::button6_Click);
//
// button7

//
this->button7->Location = System::Drawing::Point(47, 250
);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(94, 23);
this->button7->TabIndex = 18;
this->button7->Text = L"Iskljui neparne";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this,
&Form1::button7_Click);
//
// button8
//
this->button8->Location = System::Drawing::Point(47, 291
);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(75, 23);
this->button8->TabIndex = 19;
this->button8->Text = L"Ukljui sve";
this->button8->UseVisualStyleBackColor = true;
this->button8->Click += gcnew System::EventHandler(this,
&Form1::button8_Click);
//
// button9
//
this->button9->Location = System::Drawing::Point(47, 339
);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(75, 23);
this->button9->TabIndex = 20;
this->button9->Text = L"Iskljui sve";
this->button9->UseVisualStyleBackColor = true;
this->button9->Click += gcnew System::EventHandler(this,
&Form1::button9_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13
);
this->AutoScaleMode = System::Windows::Forms::AutoScaleM
ode::Font;
this->ClientSize = System::Drawing::Size(1083, 444);
this->Controls->Add(this->button9);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->button4);
this->Controls->Add(this->button5);
this->Controls->Add(this->button3);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->checkBox8);
this->Controls->Add(this->checkBox7);
this->Controls->Add(this->checkBox6);
this->Controls->Add(this->checkBox5);
this->Controls->Add(this->checkBox4);
this->Controls->Add(this->checkBox3);
this->Controls->Add(this->checkBox2);
this->Controls->Add(this->checkBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);

this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::F
orm1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static int OpenDevice(int CardAddress);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void CloseDevice();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static int ReadAnalogChannel(int Channel);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void ReadAllAnalog(int *Data1, int *Data2);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void OutputAnalogChannel(int Channel, int Data);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void OutputAllAnalog(int Data1, int Data2);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void ClearAnalogChannel(int Channel);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void SetAllAnalog();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void ClearAllAnalog();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void SetAnalogChannel(int Channel);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void WriteAllDigital(int Data);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void ClearDigitalChannel(int Channel);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void ClearAllDigital();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void SetDigitalChannel(int Channel);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void SetAllDigital();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static bool ReadDigitalChannel(int Channel);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]

static int ReadAllDigital();


[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static int ReadCounter(int CounterNr);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void ResetCounter(int CounterNr);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void SetCounterDebounceTime(int CounterNr, int DebounceTime);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static int Version();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static int SearchDevices();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static int SetCurrentDevice(int lngCardAddress);
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static int ReadBackDigitalOut();
[DllImport("k8055d.dll", CharSet=CharSet::Ansi)]
static void ReadBackAnalogOut(int *Buffer);
private: System::Void Form1_Load(System::Object^ sender, System::EventA
rgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::Eve
ntArgs^ e)
{
int a = OpenDevice(0);
if (a == 0)
{
textBox1->Text="Kartica povezana";
}
else
{
textBox1->Text="Kartica nije spojena";
}
}
private: System::Void button2_Click(System::Object^ sender, System::Eve
ntArgs^ e)
{
CloseDevice();
textBox1->Text="Kartica odspojena";
}
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::
EventArgs^ e)
{
checkBox1->Checked ? SetDigitalChannel(1): ClearDigital
Channel(1);
}
private: System::Void checkBox2_CheckedChanged(System::Object^ sender, System::
EventArgs^ e)
{
checkBox2->Checked ? SetDigitalChannel(2): ClearDigital
Channel(2);
}
private: System::Void checkBox3_CheckedChanged(System::Object^ sender, System::

EventArgs^ e)
{
checkBox3->Checked ? SetDigitalChannel(3): ClearDigital
Channel(3);
}
private: System::Void checkBox4_CheckedChanged(System::Object^ sender, System::
EventArgs^ e)
{
checkBox4->Checked ? SetDigitalChannel(4): ClearDigital
Channel(4);
}
private: System::Void checkBox5_CheckedChanged(System::Object^ sender, System::
EventArgs^ e)
{
checkBox5->Checked ? SetDigitalChannel(5): ClearDigital
Channel(5);
}
private: System::Void checkBox6_CheckedChanged(System::Object^ sender, System::
EventArgs^ e)
{
checkBox6->Checked ? SetDigitalChannel(6): ClearDigital
Channel(6);
}
private: System::Void checkBox7_CheckedChanged(System::Object^ sender, System::
EventArgs^ e)
{
checkBox7->Checked ? SetDigitalChannel(7): ClearDigital
Channel(7);
}
private: System::Void checkBox8_CheckedChanged(System::Object^ sender, System::
EventArgs^ e)
{
checkBox8->Checked ? SetDigitalChannel(8): ClearDigital
Channel(8);
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^
e)
{
Form1::Close();
}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^
e)
{
SetDigitalChannel(1);
SetDigitalChannel(3);
SetDigitalChannel(5);
SetDigitalChannel(7);
checkBox1->Checked = true;
checkBox3->Checked = true;
checkBox5->Checked = true;
checkBox7->Checked = true;
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^
e)
{
SetDigitalChannel(2);
SetDigitalChannel(4);
SetDigitalChannel(6);
SetDigitalChannel(8);
checkBox2->Checked = true;

checkBox4->Checked = true;
checkBox6->Checked = true;
checkBox8->Checked = true;
}
private: System::Void button6_Click(System::Object^
e)
{
ClearDigitalChannel(2);
ClearDigitalChannel(4);
ClearDigitalChannel(6);
ClearDigitalChannel(8);
checkBox2->Checked = false;
checkBox4->Checked = false;
checkBox6->Checked = false;
checkBox8->Checked = false;
}
private: System::Void button7_Click(System::Object^
e)
{
ClearDigitalChannel(1);
ClearDigitalChannel(3);
ClearDigitalChannel(5);
ClearDigitalChannel(7);
checkBox1->Checked = false;
checkBox3->Checked = false;
checkBox5->Checked = false;
checkBox7->Checked = false;
}
private: System::Void button8_Click(System::Object^
e)
{
SetAllDigital();
checkBox1->Checked = true;
checkBox2->Checked = true;
checkBox3->Checked = true;
checkBox4->Checked = true;
checkBox5->Checked = true;
checkBox6->Checked = true;
checkBox7->Checked = true;
checkBox8->Checked = true;
}
private: System::Void button9_Click(System::Object^
e)
{
ClearAllDigital();
checkBox1->Checked = false;
checkBox2->Checked = false;
checkBox3->Checked = false;
checkBox4->Checked = false;
checkBox5->Checked = false;
checkBox6->Checked = false;
checkBox7->Checked = false;
checkBox8->Checked = false;
}
};
}

sender, System::EventArgs^

sender, System::EventArgs^

sender, System::EventArgs^

sender, System::EventArgs^

Das könnte Ihnen auch gefallen