private void frmMonitor_Load(object sender, EventArgs e) { Cranes.OnCrane += new CraneEventHandler(Monitor_OnCrane); //picCrane1.Parent = pictureBox1; //InitialP1 = picCrane1.Location; //picCrane1.BackColor = Color.Transparent; InitialP2 = picCar01.Location; picCar01.Parent = pictureBox1; picCar01.BackColor = Color.Transparent; InitialP3 = picCar02.Location; picCar02.Parent = pictureBox1; picCar02.BackColor = Color.Transparent; //InitialP4 = picCrane2.Location; //picCrane2.Parent = pictureBox1; //picCrane2.BackColor = Color.Transparent; AddDicKeyValue(); try { ServerInfo[] Servers = new MonitorConfig("Monitor.xml").Servers; Conveyors.OnConveyor += new ConveyorEventHandler(Monitor_OnConveyor); Cars.OnCar += new CarEventHandler(Monitor_OnCar); Miniloads.OnMiniload += new MiniloadEventHandler(Monitor_OnMiniload); for (int i = 0; i < Servers.Length; i++) { OPCServer opcServer = new OPCServer(Servers[i].Name); opcServer.Connect(Servers[i].ProgID, Servers[i].ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(Servers[i].GroupName, Servers[i].UpdateRate); foreach (ItemInfo item in Servers[i].Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } if (Servers[i].Name == "TranLineServer") { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Conveyor_OnDataChanged); } if (Servers[i].Name == "Car0101Server" || Servers[i].Name == "Car0102Server") { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Car_OnDataChanged); } if (Servers[i].Name == "MiniloadServer") { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Miniload_OnDataChanged); } } } catch (Exception ex) { Logger.Error(ex.Message); } //tmCrane1.Interval = 3000; //tmCrane1.Elapsed += new System.Timers.ElapsedEventHandler(tmCraneWorker1); //tmCrane1.Start(); }
private void frmMonitor_Load(object sender, EventArgs e) { AddDicKeyValue(); try { dtCraneError = bll.FillDataTable("WCS.SelectCraneWarning"); for (int i = 1; i <= 5; i++) { Control[] ctl = this.Controls.Find("picCrane" + i.ToString(), true); if (ctl.Length > 0) { ((PictureBox)ctl[0]).Parent = pictureBox1; ((PictureBox)ctl[0]).BackColor = Color.Transparent; } } for (int i = 101; i <= 120; i++) { Control[] ctl = this.Controls.Find("picCar" + i.ToString(), true); if (ctl.Length > 0) { ((PictureBox)ctl[0]).Visible = false; ((PictureBox)ctl[0]).Parent = pictureBox1; ((PictureBox)ctl[0]).BackColor = Color.Transparent; } } PLCS.OnPLC += new PLCEventHandler(Monitor_OnPLC); Cranes.OnCrane += new CraneEventHandler(Monitor_OnCrane); ServerInfo[] Servers = new MonitorConfig("Monitor.xml").Servers; for (int i = 0; i < Servers.Length; i++) { OPCServer opcServer = new OPCServer(Servers[i].Name); opcServer.Connect(Servers[i].ProgID, Servers[i].ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(Servers[i].GroupName, Servers[i].UpdateRate); foreach (ItemInfo item in Servers[i].Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } if (Servers[i].Name == "CarServer") { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(CarServer_OnDataChanged); } else { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(CraneServer_OnDataChanged); } } tmCrane.Interval = 2000; tmCrane.Elapsed += new System.Timers.ElapsedEventHandler(tmCraneWorker); tmCrane.Start(); } catch (Exception ex) { Logger.Error("监控界面中frmMonitor_Load出现异常" + ex.Message); } }
private void frmMonitorA_Load(object sender, EventArgs e) { DataTable dt = Program.dtUserPermission; //监控任务--取消堆垛机任务 string filter = "SubModuleCode='MNU_W00A_00A' and OperatorCode='1'"; DataRow[] drs = dt.Select(filter); if (drs.Length <= 0) { this.btnCancel1.Visible = false; this.btnCancel2.Visible = false; this.btnCancel3.Visible = false; this.btnCancel4.Visible = false; } else { this.btnCancel1.Visible = true; this.btnCancel2.Visible = true; this.btnCancel3.Visible = true; this.btnCancel4.Visible = true; } Cranes.OnCrane += new CraneEventHandler(Monitor_OnCrane); InitialP1 = btnSRM1.Location; InitialP2 = btnSRM2.Location; InitialP3 = btnSRM3.Location; InitialP4 = btnSRM4.Location; AddDicKeyValue(); try { ServerInfo[] Servers = new MonitorConfig("MonitorA.xml").Servers; for (int i = 0; i < Servers.Length; i++) { OPCServer opcServer = new OPCServer(Servers[i].Name); opcServer.Connect(Servers[i].ProgID, Servers[i].ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(Servers[i].GroupName, Servers[i].UpdateRate); foreach (ItemInfo item in Servers[i].Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } if (Servers[i].Name.IndexOf("PLC") >= 0) { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Crane_OnDataChanged); } } } catch (Exception ex) { Logger.Error(ex.Message); } tmWorkTimer.Interval = Program.SendInterval; tmWorkTimer.Elapsed += new System.Timers.ElapsedEventHandler(tmWorker); tmWorkTimer.Start(); }
private void frmMonitor_Load(object sender, EventArgs e) { DataTable dt = Program.dtUserPermission; //监控任务--取消堆垛机任务 string filter = "SubModuleCode='MNU_W00A_00A' and OperatorCode='1'"; DataRow[] drs = dt.Select(filter); if (drs.Length <= 0) { this.btnCancel0101.Visible = false; } else { this.btnCancel0101.Visible = true; } P2 = pictureBox2.Location; AddDicKeyValue(); Cranes.OnCrane += new CraneEventHandler(Monitor_OnCrane); Conveyors.OnConveyor+=new ConveyorEventHandler(Conveyors_OnConveyor); try { ServerInfo[] Servers = new MonitorConfig("Monitor.xml").Servers; for (int i = 0; i < Servers.Length; i++) { OPCServer opcServer = new OPCServer(Servers[i].Name); opcServer.Connect(Servers[i].ProgID, Servers[i].ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(Servers[i].GroupName, Servers[i].UpdateRate); foreach (ItemInfo item in Servers[i].Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } if (Servers[i].Name.IndexOf("CranePLC") >= 0) { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(CranePLC_OnDataChanged); } if (Servers[i].Name.IndexOf("Convey") >= 0) { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Convey_OnDataChanged); } } } catch (Exception ex) { Logger.Error(ex.Message); } }
public override void Initialize(string file) { opcServer = new OPCServer(Name); Config.Configuration config = new Config.Configuration(file); opcServer.Connect(config.ProgID, config.ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(config.GroupName, config.UpdateRate); foreach (Config.ItemInfo item in config.Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(DefaultGroup_OnDataChanged); }
private void frmMonitor_Load(object sender, EventArgs e) { AddDicKeyValue(); try { ServerInfo[] Servers = new MonitorConfig("Monitor.xml").Servers; Miniloads.OnMiniload += new MiniloadEventHandler(Monitor_OnMiniload); System.Threading.Thread.Sleep(300); Cranes.OnCrane += new CraneEventHandler(Monitor_OnCrane); for (int i = 0; i < Servers.Length; i++) { OPCServer opcServer = new OPCServer(Servers[i].Name); opcServer.Connect(Servers[i].ProgID, Servers[i].ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(Servers[i].GroupName, Servers[i].UpdateRate); foreach (ItemInfo item in Servers[i].Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } //if (Servers[i].Name == "TranLineServer") //{ // opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Conveyor_OnDataChanged); //} //if (Servers[i].Name == "Car0101Server" || Servers[i].Name == "Car0102Server") //{ // //opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Car_OnDataChanged); //} if (Servers[i].Name.IndexOf("MiniloadServer") >= 0) { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Miniload_OnDataChanged); } if (Servers[i].Name.IndexOf("CraneServer") >= 0) { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Crane_OnDataChanged); } } } catch (Exception ex) { Logger.Error(ex.Message); } }
private void frmMonitorB_Load(object sender, EventArgs e) { Cranes.OnCrane += new CraneEventHandler(Monitor_OnCrane); InitialP5 = btnSRM5.Location; InitialP6 = btnSRM6.Location; InitialP7 = btnSRM7.Location; AddDicKeyValue(); try { ServerInfo[] Servers = new MonitorConfig("MonitorB.xml").Servers; for (int i = 0; i < Servers.Length; i++) { OPCServer opcServer = new OPCServer(Servers[i].Name); opcServer.Connect(Servers[i].ProgID, Servers[i].ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(Servers[i].GroupName, Servers[i].UpdateRate); foreach (ItemInfo item in Servers[i].Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } if (Servers[i].Name.IndexOf("PLC") >= 0) { opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(Crane_OnDataChanged); } } } catch (Exception ex) { Logger.Error(ex.Message); } tmWorkTimer.Interval = 30000; tmWorkTimer.Elapsed += new System.Timers.ElapsedEventHandler(tmWorker); tmWorkTimer.Start(); }