2016년 7월 13일 수요일

C# 델리게이트 (delegate)


1. 델리게이트는 모양이다.
2. 델리게이트에서 정한 모양을 따르는 메소드를 등록할 수 있다.

ex>

1. 델리게이트 정의

delegate void GoodMan(int value);
-> GoodMan 이라는 델리게이트는 입력 파라미터를 int value 를 같는 모양이다.

2. 델리게이트의 인스턴스 생성 (GoodMan이라는 델리게이트, 즉 클래스 같은걸 1 에서 만든거다.)

GoodMan yoamn = new GoodMan(Method);

-> 이제는 yoman = Method 가 됬다. Method 를 호출할때 Method로 해도, yoman 으로 해도 된다.

3. 다른 메소드 등록

그다음에 yoman을 method2 로 바꾸고 싶을때

yoman = new GoodMan(method2);
yoman = method2

이 둘중 하나를 쓰면 이제 yoman 은 method2 가 된다.

c# 쓰레드 윈폼 (Thread winform)


먼저 쓰레드를 생성하고, Thread_Test1 을 시작한다.

그러면 크로스 스레드 예외가 난다.

윈폼에서는 컨트롤들에 접근할 수 있는 스레드는, 처음에 컨트롤들을 만든 스레드 하나뿐이다.

따라서,처음에 컨트롤을 만든 쓰레드가 있는데, 다른 쓰레드를 만들고 이쓰레드가 프로그래스바 에 접근할려고 해서 이 예외가 발생한 것이다.






--------------------------------------------------------------------------------------------------
Thread tr
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
tr = new Thread(Thread_Test1);
tr.Start();


}

public void Thread_Test1()
{
try
{
progressBar1.Minimum = 0;
progressBar1.Maximum = 1000000; //프로그래스의 최대값을 설정
for (int i = 0; i < 1000000; i++) // for문을 이용해 프로그래스바의 값을 변경해 줍니다
{
progressBar1.Value = i;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

2016년 7월 3일 일요일

Keithley SMU2600 Series Control Program (제어 프로그램)


Keithley SMU2600 Series Control Program 입니다.

기본 측정과 공장 스크립트 구현해 놨습니다. 공장 스크립트는 Linear Sweep 만 구현해 놨습니다.

이번주 내로 트리거까지 작업해서 다시 올릴 계획입니다.



https://app.box.com/s/2pbyl3xn4hbbqbdg3bzbythhqxcc0rv9

2016년 6월 30일 목요일

CRLF에 대해


텍스트의 한행의 끝을 나타내는 코드이다.

종류로는 CR , LF , CRLF 가 있다.

CR : Carriage Return = \r

LF : Line Feed = \n

의 약자이고, OS 마다 다르다.


Window,Dos : CRLF = \r\n

Mac Os : CR = \r

OS X, Unix : LF = \n

** 아스키 코드로는 (16진수로)

CR = 0D

LF = 0A

2016년 6월 29일 수요일

Keithley .Net 프로그래밍을 위한 셋업


IVI Shared Component .NET 드라이버 설치

IVI Shared Component 드라이버 설치

Keithley IVI-COM Driver for Series 설치

장비 기초 : C# 으로 RS232 장비 컨트롤 하는법 [VISA 이용]



1. 장비가 VISA 를 지원하는지 NI 에서 확인

2. 레퍼런스로 NationalInstruments.Common , NationalInstruments.VisaNS 추가

3. using NationalInstruments.VisaNS;

4. MessageBasedSession mbSession =
(MessageBasedSession)ResourceManager.GetLocalManager().Open(ResourceName);

5. 리소스 이름은 다음으로 찾을 수 있다.


string[] sourcelist = ResourceManager.GetLocalManager().FindResources("?*");
foreach (string name in sourcelist)
{
lbxSourceList.Items.Add(name);
}



5. 이제 Quart, Write, Read 를 사용해본다 .

mbSession.Write(text);
string result = mbSession.Query(text);
string result = mbSession.ReadString();


6. Dispose

mbSession.Dispose();

2016년 6월 28일 화요일

Min Max 찾는 프로그램

매우 단순한 Min Max찾는 프로그램입니다.

엑셀에서 X Y 리스트 드래그후 클립보드에 복사,

프로그램의 로드버튼 누르면 알아서 XY 그래프 그려지고 , 찾고싶은 범위를 그래프에서 마우스 클릭으로 설정하면 자동으로 Min Max값이 표시됩니다.


나중에 시간되면 자동으로 로컬 최대 최소 값을 자동으로 찾을 수 있게 할겁니다.



https://app.box.com/s/wv80kxvwxjx5q89ricero7y2kgvvfo2q

실행은 Peakfind.exe로