⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitmain.~pas

📁 delphi基于工业控制的串口通讯
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
        begin
            ResultVlues:=Myini.ReadInteger('GoOnWarnSet','ResultVlues',0);
            if ResultVlues=1 then
            begin
                LostVlues:=0;
            end
            else
            begin
                LostVlues:=1;
            end;
        end;
        Myini.Free;
    except
        Myini.Free;
    end;
end;
procedure Tfrm_Main.Cmd_CancelClick(Sender: TObject);
begin
    if Application.MessageBox('你确定需要退出本系统吗?请确认!',Pchar(Application.Title),MB_OKCancel)=IDOK then
    begin
        if Cmd_openTime.Caption='关闭定时(&T)' then
        begin
            Cmd_OpenTimeClick(Sender);
        end;
        if MyQueryThread<>nil then
        begin
            MyQueryThread.Terminate;
        end;
        {if MySpcomm<>nil then
        begin
            MySpcomm.destroy;
        end;}
        sleep(100);
        system.Halt;
    end;
end;

procedure Tfrm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    {if MySpcomm<>nil then
    begin
        MySpcomm.destroy;
    end;
    if MyQueryThread<>nil then
    begin
        MyQueryThread.Terminate;
    end;  }
    Action:=Cafree;
    system.Halt;
end;

procedure Tfrm_Main.Cmd_EquipmentSetClick(Sender: TObject);
var
    MyForm: Tfrm_EquipmentConfig;
begin
    MyForm:=Tfrm_EquipmentConfig.Create(Self);
    MyForm.ShowModal;
    MyForm.Free;
end;

procedure Tfrm_Main.Cmd_EquipmentSearchClick(Sender: TObject);
var
    MyForm: Tfrm_EquipmetSearch;
begin
    MyForm:=Tfrm_EquipmetSearch.Create(Self);
    MyForm.ShowModal;
    MyForm.Free;
end;

procedure Tfrm_Main.FormDestroy(Sender: TObject);
begin
    if MySpcomm<>nil then
    begin
        MySpcomm.destroy;
    end;
    if MyQueryThread<>nil then
    begin
        MyQueryThread.Terminate;
    end;
end;

procedure Tfrm_Main.FormShow(Sender: TObject);
begin
    Initinfo(Sender);
end;
//系统主窗体创建的时候把设备控制模块创建
procedure Tfrm_Main.FormCreate(Sender: TObject);
begin
    ReadRegeditName;
    if MySpcomm=nil then
    begin
        MySpcomm:=TSpcomm.Create(self);
        MySpcomm.Start;
    end;
    MyPlayer:=TMyPlayer.Create(self);
    MyPlayer.Visible:=False;
    Parent:=frm_Main;
    WriteRegistry;
    SysInfo := StringOfChar(' ', 2) + '【总线制报警系统1.01版】版本:V1.0.1 Beta   软件制作: 四川赛普 (C) 2003-2005' + StringOfChar(' ', 2);
end;

procedure Tfrm_Main.Cmd_ConfigClick(Sender: TObject);
var
    MyForm: Tfrm_SystemConfig;
begin
    MyForm:=Tfrm_SystemConfig.Create(Self);
    MyForm.ShowModal;
    Myform.Free;
end;

procedure Tfrm_Main.Timer1Timer(Sender: TObject);
var
    j,Len1:integer;
    Str1,Str2:String;
begin
    L_NowWeek.Caption:='当前星期:'+NowWeek(now);
    L_Date.Caption   :='当前日期:'+ForMatdatetime('yyyy''-''mm''-''dd',now);
    L_Time.Caption   :='当前时间:'+ForMatdatetime('hh'':''mm'':''ss',now);
    //动态显示信息
    StatusBar1.Panels[3].Text := Copy(SoftMake, DisPos * 2 + 1, Length(SoftMake));
    Inc(DisPos);
    if DisPos * 2 + 1 > Length(SoftMake) - 1 then
    DisPos := 0;
    //:=Myini.ReadString('SoftUserSet','UserName','');
    //        :=Myini.ReadString('SoftUserSet','SoftName','');
    {str1:=SoftUserName+' '+SoftName;
    Label1.Caption:=Str1;
    if Label1.Left>Width then
        Label1.Left:=-Label1.Width
    else
        Label1.Left:= Label1.Left+1;}
end;

procedure Tfrm_Main.Cmd_CloseAllClick(Sender: TObject);
begin
    PAvi.Visible:=False;
end;


procedure Tfrm_Main.Cmd_OpenAllClick(Sender: TObject);
begin
    PAvi.Visible:=True;
end;
procedure Tfrm_Main.Cmd_OpenTimeClick(Sender: TObject);
begin
    if Cmd_OpenTime.Caption='关闭定时(&T)' then
    begin
        OffTime;
        if MyPlayer<>nil then
        begin
            MyPlayer.Close;
        end;
        Cmd_OpenTime.Caption:='打开定时(&T)';
    end
    else if Cmd_OpenTime.Caption='打开定时(&T)' then
    begin
        OnTime;
        if MyPlayer=nil then
        begin
            MyPlayer:=TMyPlayer.Create(self);
            Parent:=frm_Main;
        end;
        Cmd_OpenTime.Caption:='关闭定时(&T)';
    end;
end;

procedure Tfrm_Main.Cmd_RCOKClick(Sender: TObject);
begin
    if RadioButton1.Checked=True then
    begin
        MySpcomm.ReadContStatus(StrToInt(Edit_Cont.Text));
        SendMsg;
    end;
    if RadioButton2.Checked=True then
    begin
        MySpcomm.ReadContAddress;
        SendMsg;
    end;
    if RadioButton3.Checked=True then
    begin
        MySpcomm.ReadContTerminalCount(StrToInt(Edit_Cont.Text));
        SendMsg;
    end;
    if RadioButton4.Checked=True then
    begin
        MySpcomm.ReadIPStates(StrToInt(Edit_Cont.Text));
        SendMsg;
    end;
end;

procedure Tfrm_Main.Cmd_RTOKClick(Sender: TObject);
begin
    if RadioButton7.Checked=True then
    begin
        MySpcomm.ReadTerminalStatus(StrToInt(Trim(Edit_TCount.Text)),StrToInt(Trim(Edit_TTerminal.Text)));
        SendMsg;
    end;
    if RadioButton8.Checked=True then
    begin
        MySpcomm.ReadTerminalAddr;
        SendMsg;
    end;
    if RadioButton9.Checked=True then
    begin
        MySpcomm.ReadTerminalSet(StrToInt(Trim(Edit_TCount.Text)),StrtoInt(Trim(Edit_TTerminal.Text)));
        SendMsg;
    end;
end;

procedure Tfrm_Main.Cmd_WCOkClick(Sender: TObject);
begin
    if RadioButton5.Checked=True then
    begin
        MySpcomm.WriteContAddr(StrToInt(Edit_Cont.Text));
        SendMsg;
    end;
    if RadioButton6.Checked=True then
    begin                        
        MySpcomm.WriteContTerminalCount(StrToInt(Edit_Cont.Text),StrToInt(Edit_TerminalCount.Text));
        SendMsg;
    end;
end;

procedure Tfrm_Main.Cmd_WTOKClick(Sender: TObject);
begin
    if RadioButton10.Checked=True then
    begin
        MySpcomm.WriteTerminalAddr(StrToInt(Trim(Edit_TTerminalAddr.Text)));
        SendMsg;
    end;
    if RadioButton11.Checked=True then
    begin
        MySpcomm.WriteTerminalSet(StrToInt(Trim(Edit_TCount.Text)),StrtoInt(Trim(Edit_TTerminal.Text)),StrToInt(Trim(Edit_TerminalSet.Text)));
        SendMsg;
    end;
end;

procedure Tfrm_Main.Cmd_RUOKClick(Sender: TObject);
begin
    if RadioButton12.Checked=True then
    begin
        MySpcomm.ReadUportSet(StrToInt(Trim(Edit_UCont.Text)),StrtoInt(Trim(Edit_UTerminal.Text)),StrtoInt(Trim(Edit_Uport.Text)));
        SendMsg;
    end;
    if RadioButton13.Checked=True then
    begin
        MySpcomm.ReadUportReader(StrToInt(Trim(Edit_UCont.Text)),StrtoInt(Trim(Edit_UTerminal.Text)),StrToInt(Trim(Edit_Uport.Text)));
        SendMsg;
        //Edit_UportData.Text:=IntTostr(MySpcomm.ReadUportAmount(StrToInt(Trim(Edit_UCont.Text)),StrtoInt(Trim(Edit_UTerminal.Text)),StrToInt(Trim(Edit_Uport.Text))));
    end;
    if RadioButton14.Checked=True then
    begin
        MySpcomm.ReadUportOpenClose(StrToInt(Trim(Edit_UCont.Text)),StrtoInt(Trim(Edit_UTerminal.Text)),StrToInt(Edit_Uport.Text));
        SendMsg;
    end;
end;

procedure Tfrm_Main.Cmd_WUOKClick(Sender: TObject);
Var
    OpenCode:Integer;
begin
    if RadioButton15.Checked=True then
    begin
        if Trim(Edit_UportSet.Text)='' then Exit;
        OpenCode:=StrToInt(ReadUportOption(Trim(Edit_UportSet.Text)));
        MySpcomm.WriteUportSet(StrToInt(Trim(Edit_UCont.Text)),StrtoInt(Trim(Edit_UTerminal.Text)),StrToInt(Trim(Edit_Uport.Text)),OpenCode);
        SendMsg;
    end;
    if RadioButton16.Checked=True then
    begin
        MySpcomm.WriteUportReader(StrToInt(Trim(Edit_UCont.Text)),StrtoInt(Trim(Edit_UTerminal.Text)),StrToInt(Trim(Edit_Uport.Text)),StrToInt64(Trim(Edit_UportData.Text)));
        SendMsg;
    end;
    if RadioButton17.Checked=True then
    begin
        MySpcomm.WriteUportOpenClose(StrToInt(Trim(Edit_UCont.Text)),StrtoInt(Trim(Edit_UTerminal.Text)),StrToInt(Trim(Edit_Uport.Text)),Edit_UportLock.ItemIndex);
        SendMsg;
    end;
end;

procedure Tfrm_Main.Cmd_HideClick(Sender: TObject);
begin
    GroupBox1.Visible:=False;
end;

procedure Tfrm_Main.Cmd_TestClick(Sender: TObject);
begin
    GroupBox1.Visible:=True;
end;

procedure Tfrm_Main.WarnImage1Click(Sender: TObject);
begin
    LostWarn('01号',WarnImage1,WarnAnimate1);
end;

procedure Tfrm_Main.WarnImage2Click(Sender: TObject);
begin
    LostWarn('02号',WarnImage2,WarnAnimate2);
end;

procedure Tfrm_Main.WarnImage3Click(Sender: TObject);
begin
    LostWarn('03号',WarnImage3,WarnAnimate3);
end;

procedure Tfrm_Main.WarnImage4Click(Sender: TObject);
begin
    LostWarn('04号',WarnImage4,WarnAnimate4);
end;

procedure Tfrm_Main.WarnImage5Click(Sender: TObject);
begin
    LostWarn('05号',WarnImage5,WarnAnimate5);
end;

procedure Tfrm_Main.WarnImage6Click(Sender: TObject);
begin
    LostWarn('06号',WarnImage6,WarnAnimate6);
end;

procedure Tfrm_Main.WarnImage16Click(Sender: TObject);
begin
    LostWarn('16号',WarnImage16,WarnAnimate16);
end;

procedure Tfrm_Main.WarnImage15Click(Sender: TObject);
begin
    LostWarn('15号',WarnImage15,WarnAnimate15);
end;

procedure Tfrm_Main.WarnImage14Click(Sender: TObject);
begin
    LostWarn('14号',WarnImage14,WarnAnimate14);
end;

procedure Tfrm_Main.WarnImage13Click(Sender: TObject);
begin
    LostWarn('13号',WarnImage13,WarnAnimate13);
end;

procedure Tfrm_Main.WarnImage12Click(Sender: TObject);
begin
    LostWarn('12号',WarnImage12,WarnAnimate12);
end;

procedure Tfrm_Main.WarnImage11Click(Sender: TObject);
begin
    LostWarn('11号',WarnImage11,WarnAnimate11);
end;

procedure Tfrm_Main.WarnImage9Click(Sender: TObject);
begin
    LostWarn('09号',WarnImage9,WarnAnimate9);
end;

procedure Tfrm_Main.WarnImage10Click(Sender: TObject);
begin
    LostWarn('10号',WarnImage10,WarnAnimate10);
end;

procedure Tfrm_Main.WarnImage7Click(Sender: TObject);
begin
    LostWarn('07号',WarnImage7,WarnAnimate7);
end;

procedure Tfrm_Main.WarnImage8Click(Sender: TObject);
begin
    LostWarn('08号',WarnImage8,WarnAnimate8);
end;

procedure Tfrm_Main.Cmd_WarnLogClick(Sender: TObject);
var
    MyForm: Tfrm_WarnInfoSearch;
begin
    MyForm:=Tfrm_WarnInfoSearch.Create(Self);
    MyForm.ShowModal;
    MyForm.Free;
end;

procedure Tfrm_Main.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   //{屏蔽 ALT+F4}
    if (shift = [ssAlt]) and (key = vk_F4) then
    begin
        shift := [];
        key := 0;
    end;
end;

procedure Tfrm_Main.FormActivate(Sender: TObject);
begin
   // if frm_main.Tag = 0 then frm_login.ShowModal;
end;

procedure Tfrm_Main.Cmd_UserClick(Sender: TObject);
begin
    frm_UserConfg:=Tfrm_UserConfg.Create(self);
    frm_UserConfg.ShowModal;
    frm_UserConfg.Free;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -