달력

122024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'Delphi'에 해당되는 글 2건

  1. 2015.01.02 key code
  2. 2012.01.05 Modbus RTU sample DOC [PDF]
  { Virtual Keys, Standard Set }
  {$EXTERNALSYM VK_LBUTTON}
  VK_LBUTTON = 1;
  {$EXTERNALSYM VK_RBUTTON}
  VK_RBUTTON = 2;
  {$EXTERNALSYM VK_CANCEL}
  VK_CANCEL = 3;
  {$EXTERNALSYM VK_MBUTTON}
  VK_MBUTTON = 4;  { NOT contiguous with L & RBUTTON }
  {$EXTERNALSYM VK_BACK}
  VK_BACK = 8;
  {$EXTERNALSYM VK_TAB}
  VK_TAB = 9;
  {$EXTERNALSYM VK_CLEAR}
  VK_CLEAR = 12;
  {$EXTERNALSYM VK_RETURN}
  VK_RETURN = 13;
  {$EXTERNALSYM VK_SHIFT}
  VK_SHIFT = $10;
  {$EXTERNALSYM VK_CONTROL}
  VK_CONTROL = 17;
  {$EXTERNALSYM VK_MENU}
  VK_MENU = 18;
  {$EXTERNALSYM VK_PAUSE}
  VK_PAUSE = 19;
  {$EXTERNALSYM VK_CAPITAL}
  VK_CAPITAL = 20;
  {$EXTERNALSYM VK_KANA }
  VK_KANA = 21;
  {$EXTERNALSYM VK_HANGUL }
  VK_HANGUL = 21;
  {$EXTERNALSYM VK_JUNJA }
  VK_JUNJA = 23;
  {$EXTERNALSYM VK_FINAL }
  VK_FINAL = 24;
  {$EXTERNALSYM VK_HANJA }
  VK_HANJA = 25;
  {$EXTERNALSYM VK_KANJI }
  VK_KANJI = 25;
  {$EXTERNALSYM VK_CONVERT }
  VK_CONVERT = 28;
  {$EXTERNALSYM VK_NONCONVERT }
  VK_NONCONVERT = 29;
  {$EXTERNALSYM VK_ACCEPT }
  VK_ACCEPT = 30;
  {$EXTERNALSYM VK_MODECHANGE }
  VK_MODECHANGE = 31;
  {$EXTERNALSYM VK_ESCAPE}
  VK_ESCAPE = 27;
  {$EXTERNALSYM VK_SPACE}
  VK_SPACE = $20;
  {$EXTERNALSYM VK_PRIOR}
  VK_PRIOR = 33;
  {$EXTERNALSYM VK_NEXT}
  VK_NEXT = 34;
  {$EXTERNALSYM VK_END}
  VK_END = 35;
  {$EXTERNALSYM VK_HOME}
  VK_HOME = 36;
  {$EXTERNALSYM VK_LEFT}
  VK_LEFT = 37;
  {$EXTERNALSYM VK_UP}
  VK_UP = 38;
  {$EXTERNALSYM VK_RIGHT}
  VK_RIGHT = 39;
  {$EXTERNALSYM VK_DOWN}
  VK_DOWN = 40;
  {$EXTERNALSYM VK_SELECT}
  VK_SELECT = 41;
  {$EXTERNALSYM VK_PRINT}
  VK_PRINT = 42;
  {$EXTERNALSYM VK_EXECUTE}
  VK_EXECUTE = 43;
  {$EXTERNALSYM VK_SNAPSHOT}
  VK_SNAPSHOT = 44;
  {$EXTERNALSYM VK_INSERT}
  VK_INSERT = 45;
  {$EXTERNALSYM VK_DELETE}
  VK_DELETE = 46;
  {$EXTERNALSYM VK_HELP}
  VK_HELP = 47;
{ VK_0 thru VK_9 are the same as ASCII '0' thru '9' ($30 - $39) }
{ VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' ($41 - $5A) }
  {$EXTERNALSYM VK_LWIN}
  VK_LWIN = 91;
  {$EXTERNALSYM VK_RWIN}
  VK_RWIN = 92;
  {$EXTERNALSYM VK_APPS}
  VK_APPS = 93;
  {$EXTERNALSYM VK_NUMPAD0}
  VK_NUMPAD0 = 96;
  {$EXTERNALSYM VK_NUMPAD1}
  VK_NUMPAD1 = 97;
  {$EXTERNALSYM VK_NUMPAD2}
  VK_NUMPAD2 = 98;
  {$EXTERNALSYM VK_NUMPAD3}
  VK_NUMPAD3 = 99;
  {$EXTERNALSYM VK_NUMPAD4}
  VK_NUMPAD4 = 100;
  {$EXTERNALSYM VK_NUMPAD5}
  VK_NUMPAD5 = 101;
  {$EXTERNALSYM VK_NUMPAD6}
  VK_NUMPAD6 = 102;
  {$EXTERNALSYM VK_NUMPAD7}
  VK_NUMPAD7 = 103;
  {$EXTERNALSYM VK_NUMPAD8}
  VK_NUMPAD8 = 104;
  {$EXTERNALSYM VK_NUMPAD9}
  VK_NUMPAD9 = 105;
  {$EXTERNALSYM VK_MULTIPLY}
  VK_MULTIPLY = 106;
  {$EXTERNALSYM VK_ADD}
  VK_ADD = 107;
  {$EXTERNALSYM VK_SEPARATOR}
  VK_SEPARATOR = 108;
  {$EXTERNALSYM VK_SUBTRACT}
  VK_SUBTRACT = 109;
  {$EXTERNALSYM VK_DECIMAL}
  VK_DECIMAL = 110;
  {$EXTERNALSYM VK_DIVIDE}
  VK_DIVIDE = 111;
  {$EXTERNALSYM VK_F1}
  VK_F1 = 112;
  {$EXTERNALSYM VK_F2}
  VK_F2 = 113;
  {$EXTERNALSYM VK_F3}
  VK_F3 = 114;
  {$EXTERNALSYM VK_F4}
  VK_F4 = 115;
  {$EXTERNALSYM VK_F5}
  VK_F5 = 116;
  {$EXTERNALSYM VK_F6}
  VK_F6 = 117;
  {$EXTERNALSYM VK_F7}
  VK_F7 = 118;
  {$EXTERNALSYM VK_F8}
  VK_F8 = 119;
  {$EXTERNALSYM VK_F9}
  VK_F9 = 120;
  {$EXTERNALSYM VK_F10}
  VK_F10 = 121;
  {$EXTERNALSYM VK_F11}
  VK_F11 = 122;
  {$EXTERNALSYM VK_F12}
  VK_F12 = 123;
  {$EXTERNALSYM VK_F13}
  VK_F13 = 124;
  {$EXTERNALSYM VK_F14}
  VK_F14 = 125;
  {$EXTERNALSYM VK_F15}
  VK_F15 = 126;
  {$EXTERNALSYM VK_F16}
  VK_F16 = 127;
  {$EXTERNALSYM VK_F17}
  VK_F17 = 128;
  {$EXTERNALSYM VK_F18}
  VK_F18 = 129;
  {$EXTERNALSYM VK_F19}
  VK_F19 = 130;
  {$EXTERNALSYM VK_F20}
  VK_F20 = 131;
  {$EXTERNALSYM VK_F21}
  VK_F21 = 132;
  {$EXTERNALSYM VK_F22}
  VK_F22 = 133;
  {$EXTERNALSYM VK_F23}
  VK_F23 = 134;
  {$EXTERNALSYM VK_F24}
  VK_F24 = 135;
  {$EXTERNALSYM VK_NUMLOCK}
  VK_NUMLOCK = 144;
  {$EXTERNALSYM VK_SCROLL}
  VK_SCROLL = 145;
{ VK_L & VK_R - left and right Alt, Ctrl and Shift virtual keys.
  Used only as parameters to GetAsyncKeyState() and GetKeyState().
  No other API or message will distinguish left and right keys in this way. }
  {$EXTERNALSYM VK_LSHIFT}
  VK_LSHIFT = 160;
  {$EXTERNALSYM VK_RSHIFT}
  VK_RSHIFT = 161;
  {$EXTERNALSYM VK_LCONTROL}
  VK_LCONTROL = 162;
  {$EXTERNALSYM VK_RCONTROL}
  VK_RCONTROL = 163;
  {$EXTERNALSYM VK_LMENU}
  VK_LMENU = 164;
  {$EXTERNALSYM VK_RMENU}
  VK_RMENU = 165;
  {$EXTERNALSYM VK_PROCESSKEY}
  VK_PROCESSKEY = 229;
  {$EXTERNALSYM VK_ATTN}
  VK_ATTN = 246;
  {$EXTERNALSYM VK_CRSEL}
  VK_CRSEL = 247;
  {$EXTERNALSYM VK_EXSEL}
  VK_EXSEL = 248;
  {$EXTERNALSYM VK_EREOF}
  VK_EREOF = 249;
  {$EXTERNALSYM VK_PLAY}
  VK_PLAY = 250;
  {$EXTERNALSYM VK_ZOOM}
  VK_ZOOM = 251;
  {$EXTERNALSYM VK_NONAME}
  VK_NONAME = 252;
  {$EXTERNALSYM VK_PA1}
  VK_PA1 = 253;
  {$EXTERNALSYM VK_OEM_CLEAR}
  VK_OEM_CLEAR = 254;

ShowMessage(IntToStr(Ord(Key)));

Posted by theF
|

구글링으로 얻은 PDF

원 저작자님 감사 합니다.  ^^;



 

응용한 프로그램 소스 중 일부

 - Cport 264 사용..
 - 온도 모니터링 하는데, 가끔 뻑난단다.. 콤포 문젠지 뭔지 감이 안잡힘....젠장.





procedure TfrmMain.ComTmpRxChar(Sender: TObject; Count: Integer);
var
  i:integer;
  RX_Char:char;//수신된 값
  RX_Array:array[1..200]of string;//수신된 데이타
  rx_s : string;
begin

  //ComPort1.Readstr(rx_s,count);
  //Edit_RX.Text := Edit_RX.Text + rx_s;

  //010304021600F81BCD
  for i:=1 to count do begin
    ComTmp.Read(RX_Char,1);
    RX_Array[i]:=inttohex(byte(RX_Char),2);
    RxBuf2:=RxBuf2+RX_Array[i];
  end;

  if (18 = length(RxBuf2)) and (RxBuf2[3] = '0') and (RxBuf2[4] = '4') then begin
    FlterTmp(RxBuf2);
    Edit_Rx.Text := RxBuf2;
    ComTmp.ClearBuffer(True,True);
    RxBuf2 := '';
    exit;
  end;

  if (10 = length(RxBuf2)) and ((RxBuf2[3] = '8') and (RxBuf2[4] = '1')) or ((RxBuf2[3] = '8') and (RxBuf2[4] = '4')) then begin
    FlterTmp(RxBuf2);
    Edit_Rx.Text := RxBuf2;
    ComTmp.ClearBuffer(True,True);
    RxBuf2 := '';
    exit;
  end;



end;

procedure TfrmMain.FlterTmp(tmpstr:string);
var
  i, j, iTag,k, tmparryMax, tmparryMin : integer;
  oStr, iCut1, iCut2, iCut3, iCut4 : string;
  Dcut1, Dcut2, Dcut3, Dcut4 : real;
begin

  tmrERRch.Enabled := False;

  oStr := tmpstr;

  if tmrMoni.Enabled = False then begin
    iTag := StrToInt(edtchNo.text);
  end else begin
    iTag := BtnTmpRead.Tag;
  end;

  if Length(oStr) < 18 then begin
    workD[iTag].iValue := 0;
    workD[iTag].iValue2 := 0;

    TEdit(FindComponent('EdtTemp_'+FormatFloat('00',iTag))).Text := 'ERR';//FormatFloat('0.0',Dcut1);
    TEdit(FindComponent('EdtHy_'+FormatFloat('00',iTag))).Text := 'ERR';//FormatFloat('0.0',Dcut2);

    LogADD('CH'+FormatFloat('00',iTag)+' ERROR '+ oStr);

    if tmrMoni.Enabled = False then begin
      exit;
    end;

  end else begin
    iCut1 := Copy(oStr,1,2); //ID

    iCut2 := Copy(oStr,7,4); //온도
    iCut3 := Copy(oStr,11,4); //습도


    Dcut2 := (StrToIntDef('$'+iCut2,0))/100;
    Dcut3 := (StrToIntDef('$'+iCut3,0))/100;

    workD[iTag].iValue := Dcut2;
    workD[iTag].iValue2 := Dcut3;

    TEdit(FindComponent('EdtTemp_'+FormatFloat('00',iTag))).Text := FormatFloat('0.0',Dcut2);
    TEdit(FindComponent('EdtHy_'+FormatFloat('00',iTag))).Text := FormatFloat('0.0',Dcut3);

    //LogADD('flterRTN');

  end;

  for i:=8 downto 1 do begin
    if workD[i].ichkuse then begin
      tmparryMax := i;
      break;
    end;
  end;

  for i:=1 to 8 do begin
    if workD[i].ichkuse then begin
      tmparryMin := i;
      break;
    end;
  end;

  BtnTmpRead.Tag := BtnTmpRead.Tag +1;

  if BtnTmpRead.Tag > tmparryMax then begin
    BtnTmpRead.Tag := tmparryMin;
    Measuring;
  end;




end;

procedure TfrmMain.BtnTmpReadClick(Sender: TObject);
var
  i,j, k:integer;
  CRC_Data_Len:integer;//CRC 계산에 사용될 데이타 길이
  CRC_Data_Array:array[1..30]of byte;//CRC 계산에 사용될 데이타
  Result_CRC:Word;//계산된 CRC값
  TX_Data_Size:integer;//송신할 데이타 길이
  TX_Data_Array:array[1..32]of byte;//송신할 데이타
  tmpstr : string;
  tmpchV, tmparryMax : integer;
begin

  tmrERRch.Enabled := True;

  for i:=8 downto 1 do begin
    if workD[i].ichkuse then begin
      tmparryMax := i;
      break;
    end;
  end;

  if tmrMoni.Enabled then begin
    for k := BtnTmpRead.Tag to tmparryMax do begin
      if workD[k].ichkuse then begin
        BtnTmpRead.Tag := k;
        Break;
      end;
    end;

    tmpchV := BtnTmpRead.Tag;

    edtchNo.Text := FormatFloat('00',tmpchV);
  end;

  edtchNo.Text := FormatFloat('00',strtoint(edtchNo.Text));

  Edit_Tx.Text := edtchNo.Text + '04' + '0000' + '0002';


  CRC_Data_Len:=round(length(Edit_TX.Text)/2);
  For i:=1 to CRC_Data_Len do begin
    j:=i*2-1;
    CRC_Data_Array[i]:=byte(strtoint('$'+Edit_TX.Text[j]+Edit_TX.Text[j+1]));
  end;

  Result_CRC:=Make_CRCValue(CRC_Data_Array,CRC_Data_Len);
  EdtCRC16.Text:= inttohex(Lo(Result_CRC),2)+inttohex(Hi(Result_CRC),2);


  if (ConfD.iSimulate = True) or (ComTmp.Connected = False) then exit;

  Edit_RX.Text:='';

  tmpstr := Edit_TX.Text + EdtCRC16.Text;

  TX_Data_Size:=round(length(tmpstr)/2);

  For i:=1 to TX_Data_Size do begin
    j:=i*2-1;
    TX_Data_Array[i]:=byte(strtoint('$'+tmpstr[j]+tmpstr[j+1]));
  end;

  ComTmp.Write(TX_Data_Array,TX_Data_Size);


end;

//Table에 의한 CRC값 생성 함수
function TfrmMain.Make_CRCvalue(Data: array of byte; nByte: word): Word;
var
  CRCValue:Word;
  i:integer;
begin
  CRCvalue:=$FFFF;
  For i := 1 to nByte do
    CRCvalue := Hi(CRCvalue) XOR CRC_Table[ Data[i-1] XOR Lo(CRCvalue) ];
  Result:=CRCvalue;
end;

procedure TfrmMain.btntmrstopClick(Sender: TObject);
begin
  tmrMoni.Enabled := not tmrMoni.Enabled;

  if tmrMoni.Enabled then begin
    btntmrstop.Caption := 'Auto Run.';
  end else begin
    btntmrstop.Caption := 'Manual Run.';
  end;
end;
Posted by theF
|