unit Screen_Propar;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ScadaBase, VisMachine, VisMchb, ExtCtrls, VisDltB,
  VisStatusShape, VisZDVH, VisZDVT, jpeg, SimpleLine, PolyLine, VisButton,
  Buttons, VisZDVC, VisZDVA, VisLabel, VisDynamicPict, VisMcha, VisNumericPanel,
  frxpngimage, VisDataboard, VisCheckBox, VisControl;

type
  TScreen_ProparForm = class(TForm)
    Shape1: TShape;
    Shape3: TShape;
    Shape5: TShape;
    Shape2: TShape;
    VisMchb13: TVisMchb;
    VisMchb29: TVisMchb;
    VisMchb30: TVisMchb;
    VisMchb26: TVisMchb;
    SimpleLine29: TSimpleLine;
    VisMchb27: TVisMchb;
    VisMchb6: TVisMchb;
    SimpleLine2: TSimpleLine;
    SimpleLine3: TSimpleLine;
    SimpleLine4: TSimpleLine;
    SimpleLine5: TSimpleLine;
    SimpleLine6: TSimpleLine;
    SimpleLine7: TSimpleLine;
    SimpleLine10: TSimpleLine;
    SimpleLine11: TSimpleLine;
    VisMchb1: TVisMchb;
    VisMchb3: TVisMchb;
    VisMchb5: TVisMchb;
    Image3: TImage;
    VisMchb10: TVisMchb;
    VisMchb12: TVisMchb;
    VisMchb14: TVisMchb;
    SimpleLine30: TSimpleLine;
    VisMchb7: TVisMchb;
    VisMchb9: TVisMchb;
    VisMchb2: TVisMchb;
    VisMchb4: TVisMchb;
    VisMchb15: TVisMchb;
    VisMchb16: TVisMchb;
    VisMchb17: TVisMchb;
    SimpleLine9: TSimpleLine;
    SimpleLine12: TSimpleLine;
    SimpleLine14: TSimpleLine;
    SimpleLine15: TSimpleLine;
    SimpleLine16: TSimpleLine;
    VisMchb18: TVisMchb;
    SimpleLine17: TSimpleLine;
    SimpleLine20: TSimpleLine;
    SimpleLine21: TSimpleLine;
    SimpleLine22: TSimpleLine;
    SimpleLine23: TSimpleLine;
    VisMchb19: TVisMchb;
    SimpleLine25: TSimpleLine;
    VisMchb20: TVisMchb;
    Image5: TImage;
    Image6: TImage;
    Shape4: TShape;
    Label13: TLabel;
    Label9: TLabel;
    Label14: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    VisNumericPanel10: TVisNumericPanel;
    VisNumericPanel11: TVisNumericPanel;
    VisNumericPanel12: TVisNumericPanel;
    VisNumericPanel13: TVisNumericPanel;
    VisNumericPanel16: TVisNumericPanel;
    VisDataboard4: TVisDataboard;
    VisButton1: TVisButton;
    VisButton2: TVisButton;
    npCycleNum: TVisNumericPanel;
    VisMchb23: TVisMchb;
    VisMchb25: TVisMchb;
    VisMchb28: TVisMchb;
    VisMchb31: TVisMchb;
    VisMchb32: TVisMchb;
    VisMchb33: TVisMchb;
    VisMchb34: TVisMchb;
    SimpleLine34: TSimpleLine;
    SimpleLine35: TSimpleLine;
    SimpleLine36: TSimpleLine;
    SimpleLine37: TSimpleLine;
    SimpleLine38: TSimpleLine;
    SimpleLine39: TSimpleLine;
    SimpleLine40: TSimpleLine;
    SimpleLine44: TSimpleLine;
    SimpleLine45: TSimpleLine;
    SimpleLine46: TSimpleLine;
    SimpleLine47: TSimpleLine;
    Label48: TLabel;
    SimpleLine49: TSimpleLine;
    Label49: TLabel;
    SimpleLine48: TSimpleLine;
    SimpleLine50: TSimpleLine;
    SimpleLine51: TSimpleLine;
    Label50: TLabel;
    Image8: TImage;
    VisZDVA3: TVisZDVA;
    VisZDVA4: TVisZDVA;
    VisZDVA17: TVisZDVA;
    VisMchb24: TVisMchb;
    VisZDVA18: TVisZDVA;
    Panel4: TPanel;
    VisNumericPanel24: TVisNumericPanel;
    Image9: TImage;
    Image10: TImage;
    VisZDVA22: TVisZDVA;
    VisZDVA23: TVisZDVA;
    SimpleLine53: TSimpleLine;
    VisMchb35: TVisMchb;
    SimpleLine54: TSimpleLine;
    SimpleLine56: TSimpleLine;
    VisZDVA12: TVisZDVA;
    SimpleLine57: TSimpleLine;
    VisZDVA24: TVisZDVA;
    Image12: TImage;
    Label51: TLabel;
    Image13: TImage;
    VisZDVA25: TVisZDVA;
    VisMchb37: TVisMchb;
    VisZDVA26: TVisZDVA;
    Panel6: TPanel;
    SimpleLine59: TSimpleLine;
    SimpleLine60: TSimpleLine;
    Image14: TImage;
    VisZDVA27: TVisZDVA;
    VisZDVA28: TVisZDVA;
    VisZDVA29: TVisZDVA;
    VisZDVA30: TVisZDVA;
    VisZDVA31: TVisZDVA;
    VisZDVA32: TVisZDVA;
    SimpleLine61: TSimpleLine;
    SimpleLine62: TSimpleLine;
    SimpleLine63: TSimpleLine;
    Image15: TImage;
    Label52: TLabel;
    SimpleLine65: TSimpleLine;
    Image16: TImage;
    Image20: TImage;
    Image21: TImage;
    Shape7: TShape;
    VisNumericPanel18: TVisNumericPanel;
    VisNumericPanel20: TVisNumericPanel;
    VisNumericPanel26: TVisNumericPanel;
    VisMchb8: TVisMchb;
    Shape6: TShape;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label31: TLabel;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    VisButton3: TVisButton;
    VisButton4: TVisButton;
    Label15: TLabel;
    Label42: TLabel;
    VisNumericPanel3: TVisNumericPanel;
    VisNumericPanel4: TVisNumericPanel;
    VisNumericPanel5: TVisNumericPanel;
    VisNumericPanel6: TVisNumericPanel;
    VisNumericPanel7: TVisNumericPanel;
    VisNumericPanel8: TVisNumericPanel;
    VisNumericPanel9: TVisNumericPanel;
    VisNumericPanel14: TVisNumericPanel;
    VisNumericPanel15: TVisNumericPanel;
    VisDataboard2: TVisDataboard;
    VisNumericPanel19: TVisNumericPanel;
    VisDataboard5: TVisDataboard;
    VisMchb11: TVisMchb;
    VisDataboard6: TVisDataboard;
    VisNumericPanel22: TVisNumericPanel;
    VisNumericPanel25: TVisNumericPanel;
    pnlEmu1: TPanel;
    Label43: TLabel;
    VisCheckBox1: TVisCheckBox;
    VisCheckBox2: TVisCheckBox;
    VisCheckBox3: TVisCheckBox;
    VisCheckBox4: TVisCheckBox;
    VisCheckBox5: TVisCheckBox;
    VisCheckBox6: TVisCheckBox;
    VisCheckBox7: TVisCheckBox;
    VisCheckBox8: TVisCheckBox;
    VisCheckBox9: TVisCheckBox;
    VisNumericPanel1: TVisNumericPanel;
    pnlEmu2: TPanel;
    Label44: TLabel;
    VisCheckBox10: TVisCheckBox;
    VisCheckBox11: TVisCheckBox;
    VisCheckBox12: TVisCheckBox;
    VisCheckBox13: TVisCheckBox;
    VisCheckBox14: TVisCheckBox;
    VisCheckBox15: TVisCheckBox;
    VisCheckBox16: TVisCheckBox;
    VisCheckBox17: TVisCheckBox;
    VisCheckBox18: TVisCheckBox;
    VisNumericPanel27: TVisNumericPanel;
    btEmuClose1: TSpeedButton;
    btEmuClose2: TSpeedButton;
    btEmuOpen1: TSpeedButton;
    SpeedButton1: TSpeedButton;
    Shape8: TShape;
    Shape9: TShape;
    VisLabel3: TVisLabel;
    VisLabel4: TVisLabel;
    VisDataboard7: TVisDataboard;
    VisMchb36: TVisMchb;
    VisMchb38: TVisMchb;
    VisNumericPanel23: TVisNumericPanel;
    VisNumericPanel28: TVisNumericPanel;
    VisNumericPanel29: TVisNumericPanel;
    VisDataboard8: TVisDataboard;
    VisNumericPanel30: TVisNumericPanel;
    Label53: TLabel;
    Label54: TLabel;
    VisLabel32: TVisLabel;
    VisDataboard9: TVisDataboard;
    Label45: TLabel;
    VisNumericPanel31: TVisNumericPanel;
    VisNumericPanel32: TVisNumericPanel;
    VisDataboard10: TVisDataboard;
    Label46: TLabel;
    Label55: TLabel;
    VisLabel1: TVisLabel;
    VisDataboard1: TVisDataboard;
    Label56: TLabel;
    Label57: TLabel;
    VisNumericPanel21: TVisNumericPanel;
    VisNumericPanel33: TVisNumericPanel;
    Label58: TLabel;
    Label59: TLabel;
    Label60: TLabel;
    Label61: TLabel;
    Panel1: TPanel;
    Shape10: TShape;
    Label62: TLabel;
    Label63: TLabel;
    Label64: TLabel;
    VisDataboard11: TVisDataboard;
    VisDataboard12: TVisDataboard;
    VisZDVA1: TVisZDVA;
    SimpleLine1: TSimpleLine;
    Image1: TImage;
    VisDataboard13: TVisDataboard;
    VisLabel2: TVisLabel;
    VisLabel5: TVisLabel;
    procedure VisualDeviceClick(Sender: TObject);
    procedure TabSheetMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ScadaObjectClick(Sender: TObject; obj: TCustomScadaObject;
      var frm: TForm);
    procedure GeliosClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure StartStopClick(Sender: TObject);
    procedure emuClick(Sender: TObject);
    procedure btEmuClose1Click(Sender: TObject);
    procedure btEmuOpen1Click(Sender: TObject);
    procedure npCycleNumCustomClick(Sender: TObject);
  private
  public
  end;

var
  Screen_ProparForm: TScreen_ProparForm;

implementation
uses
  Users,
  Numbers,
  MesLogging,
  Gelios_prop,
  VisSeqdControl,
  TagStorage,
  RpVisualGlobal,
  RpVisualLegacyPanels,
  RpVisualUtils,
  RpVisualMain;


{$R *.dfm}

procedure TScreen_ProparForm.VisualDeviceClick(Sender: TObject);
begin
  _VisualDeviceClick(sender);
end;

procedure TScreen_ProparForm.TabSheetMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  _TabSheetMouseDown(Sender, Button, Shift, X, Y);
end;

procedure TScreen_ProparForm.ScadaObjectClick(Sender: TObject;
  obj: TCustomScadaObject; var frm: TForm);
begin
  _ScadaObjectClick(sender, obj, frm);
end;


procedure TScreen_ProparForm.GeliosClick(Sender: TObject);
begin
  _Gelios_Click(self, Sender, 1);
end;

procedure TScreen_ProparForm.FormCreate(Sender: TObject);
begin
  align := alClient;

end;

procedure TScreen_ProparForm.StartStopClick(Sender: TObject);
begin
  with Sender as TVisButton do
    _SaveMessageScadaObject(Sender, CaptionDown + ' маршрута', $000080FF);
end;

procedure TScreen_ProparForm.emuClick(Sender: TObject);
begin
  with Sender as TVisCheckBox do
    SaveMessageText(
          'Режим эмуляции пропаривателя',
          objCheckBox.Caption,
          Hint + ' = ' + iif(objCheckBox.Checked, 'Вкл','Выкл'), clYellow);
end;

procedure TScreen_ProparForm.btEmuClose1Click(Sender: TObject);
begin
  (Sender as TSpeedButton).Parent.Visible := False;
end;

procedure TScreen_ProparForm.btEmuOpen1Click(Sender: TObject);
begin
  if CheckAccess( PREVILEG_ADMIN, True ) then
    if Sender = btEmuOpen1 then
      pnlEmu1.Visible := True
    else
      pnlEmu2.Visible := True
end;

procedure TScreen_ProparForm.npCycleNumCustomClick(Sender: TObject);
begin

  with Sender as TVisNumericPanel do begin
    if gettagval(0) <= 0 then
      Exit;
      
    if MessageDlg('Сбросить счетчик циклов пропаривания?', mtConfirmation,
          mbOKCancel, 0) <> mrOk then
      Exit;

    SaveMessageText(
          'Сброс счетчика циклов пропаривания',
          SaveMessageStr,
          '' + IntToStr( gettagval(0) ), clYellow);
          
    settagval(0, 0);
  end;
end;

end.
