|
|
@@ -16,6 +16,7 @@ import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
import java.awt.event.WindowAdapter;
|
|
|
import java.awt.event.WindowEvent;
|
|
|
+import java.awt.Insets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Timer;
|
|
|
@@ -49,6 +50,8 @@ public class MainFrame extends JFrame {
|
|
|
public static String mes_user_code = "system";
|
|
|
/** 收到入队推送后是否自动 next */
|
|
|
public static boolean mes_auto_next_on_push = true;
|
|
|
+ /** 是否写 PLC L180(MES 允许启动);false=跳过允许/不允许信号 */
|
|
|
+ public static boolean mes_allow_enabled = true;
|
|
|
public static String sessionid = "";
|
|
|
public static String mes_gw = "";
|
|
|
public static String mes_gw1 = "";
|
|
|
@@ -170,7 +173,8 @@ public class MainFrame extends JFrame {
|
|
|
}
|
|
|
user20 = mes_user_code;
|
|
|
mes_auto_next_on_push = p.isAutoNextOnPush();
|
|
|
- // 产线开关:从 line-stations 取该线工位(1#A/B + 2#~5#),再只套 PLC IP
|
|
|
+ mes_allow_enabled = p.isMesAllowEnabled();
|
|
|
+ // 产线开关:从 line-stations 取该线工位(1#~5# 各 A/B),再只套 PLC IP
|
|
|
String line = HgLineProfiles.normalize(p.getLineProfile());
|
|
|
p.setLineProfile(line);
|
|
|
List<MesClientProperties.StationConfig> list = p.stationsOfLine(line);
|
|
|
@@ -179,8 +183,9 @@ public class MainFrame extends JFrame {
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
log.warn("产线[{}] 无工位:请在 application.yml 的 mes.line-stations.{} 配置工位", line, line);
|
|
|
} else {
|
|
|
- log.info("加载工位数={} 产线={} upload={} profile={}",
|
|
|
- list.size(), line, mes_upload_path, mes_param_profile);
|
|
|
+ log.info("加载工位数={} 产线={} upload={} profile={} mesAllow={}",
|
|
|
+ list.size(), line, mes_upload_path, mes_param_profile,
|
|
|
+ Boolean.valueOf(mes_allow_enabled));
|
|
|
for (MesClientProperties.StationConfig s : list) {
|
|
|
log.info("工位 id={} sn={} title={} side={} plc={}:{}", s.getId(), s.getStationSn(), s.getTitle(),
|
|
|
s.getFixedSide(), s.getPlcIp(), Integer.valueOf(HgLineProfiles.portOf(s.getPlcIp())));
|
|
|
@@ -262,25 +267,43 @@ public class MainFrame extends JFrame {
|
|
|
status_menu.setVisible(false);
|
|
|
user_menu.setVisible(false);
|
|
|
|
|
|
- JTabbedPane tabs = new JTabbedPane(JTabbedPane.TOP);
|
|
|
- tabs.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
- tabs.setBackground(UiTheme.BG);
|
|
|
- tabs.setBorder(new EmptyBorder(8, 8, 8, 8));
|
|
|
- tabs.setFocusable(false);
|
|
|
stationPanels.clear();
|
|
|
List<MesClientProperties.StationConfig> stations =
|
|
|
props == null ? null : props.getStations();
|
|
|
if (stations == null || stations.isEmpty()) {
|
|
|
- JLabel empty = new JLabel("请在 application.yml 配置 mes.line-stations(1#A/B + 2#~5#)", SwingConstants.CENTER);
|
|
|
+ JLabel empty = new JLabel("请在 application.yml 配置 mes.line-stations(1#~5# 各 A/B)", SwingConstants.CENTER);
|
|
|
empty.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
content.add(empty, BorderLayout.CENTER);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ // 顶部:可横向滑动的工位栏(滚动条代替小箭头,方便点选)
|
|
|
+ JPanel tabStrip = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 6));
|
|
|
+ tabStrip.setBackground(UiTheme.BG);
|
|
|
+ tabStrip.setBorder(new EmptyBorder(4, 4, 0, 4));
|
|
|
+ ButtonGroup tabGroup = new ButtonGroup();
|
|
|
+ final CardLayout cards = new CardLayout();
|
|
|
+ final JPanel cardHost = new JPanel(cards);
|
|
|
+ cardHost.setBackground(UiTheme.BG);
|
|
|
+
|
|
|
List<String> stationSnList = new ArrayList<String>();
|
|
|
+ boolean first = true;
|
|
|
for (MesClientProperties.StationConfig sc : stations) {
|
|
|
StationPanel panel = new StationPanel(sc, mes_server_ip, mes_user_code);
|
|
|
stationPanels.add(panel);
|
|
|
- tabs.addTab(panel.tabTitle(), panel);
|
|
|
+ final String key = "st-" + sc.getId();
|
|
|
+ cardHost.add(panel, key);
|
|
|
+ JToggleButton tabBtn = buildStationTabButton(panel.tabTitle(), first);
|
|
|
+ final String showKey = key;
|
|
|
+ tabBtn.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ cards.show(cardHost, showKey);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tabGroup.add(tabBtn);
|
|
|
+ tabStrip.add(tabBtn);
|
|
|
+ first = false;
|
|
|
// A/B 面工位都进工作记录查询范围
|
|
|
for (String ssn : panel.allStationSns()) {
|
|
|
if (!ssn.isEmpty() && !stationSnList.contains(ssn)) {
|
|
|
@@ -296,8 +319,55 @@ public class MainFrame extends JFrame {
|
|
|
}
|
|
|
csv.append(stationSnList.get(i));
|
|
|
}
|
|
|
- tabs.addTab("工作记录", new WorkRecordPanel(mes_server_ip, csv.toString()));
|
|
|
- content.add(tabs, BorderLayout.CENTER);
|
|
|
+ WorkRecordPanel workPanel = new WorkRecordPanel(mes_server_ip, csv.toString());
|
|
|
+ cardHost.add(workPanel, "work");
|
|
|
+ JToggleButton workBtn = buildStationTabButton("工作记录", false);
|
|
|
+ workBtn.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ cards.show(cardHost, "work");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tabGroup.add(workBtn);
|
|
|
+ tabStrip.add(workBtn);
|
|
|
+
|
|
|
+ JScrollPane tabScroll = new JScrollPane(tabStrip,
|
|
|
+ ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
|
|
|
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
|
|
+ tabScroll.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UiTheme.ACCENT));
|
|
|
+ tabScroll.getViewport().setBackground(UiTheme.BG);
|
|
|
+ tabScroll.setOpaque(false);
|
|
|
+ // 加粗横向滑动条,现场好拖
|
|
|
+ JScrollBar hBar = tabScroll.getHorizontalScrollBar();
|
|
|
+ hBar.setUnitIncrement(48);
|
|
|
+ hBar.setBlockIncrement(160);
|
|
|
+ hBar.setPreferredSize(new Dimension(Integer.MAX_VALUE, 22));
|
|
|
+
|
|
|
+ JPanel center = new JPanel(new BorderLayout(0, 0));
|
|
|
+ center.setBackground(UiTheme.BG);
|
|
|
+ center.add(tabScroll, BorderLayout.NORTH);
|
|
|
+ center.add(cardHost, BorderLayout.CENTER);
|
|
|
+ content.add(center, BorderLayout.CENTER);
|
|
|
+ cards.show(cardHost, "st-" + stations.get(0).getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工位切换按钮:高度够点,选中高亮。
|
|
|
+ */
|
|
|
+ private static JToggleButton buildStationTabButton(String title, boolean selected) {
|
|
|
+ JToggleButton btn = new JToggleButton(title == null ? "" : title);
|
|
|
+ btn.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
+ btn.setFocusable(false);
|
|
|
+ btn.setMargin(new Insets(8, 14, 8, 14));
|
|
|
+ btn.setPreferredSize(null);
|
|
|
+ Dimension pref = btn.getPreferredSize();
|
|
|
+ if (pref != null) {
|
|
|
+ btn.setPreferredSize(new Dimension(Math.max(pref.width, 96), Math.max(pref.height, 40)));
|
|
|
+ } else {
|
|
|
+ btn.setPreferredSize(new Dimension(120, 40));
|
|
|
+ }
|
|
|
+ btn.setSelected(selected);
|
|
|
+ return btn;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -433,11 +503,17 @@ public class MainFrame extends JFrame {
|
|
|
|
|
|
/**
|
|
|
* 写 L180(MES 允许启动)。关允许时:同 PLC 其它面板若仍在 HOLD 等启动,则不关,避免 1#A/B 互踩。
|
|
|
+ * {@link #mes_allow_enabled}=false 时整段跳过,不发允许也不发关闭。
|
|
|
*/
|
|
|
public static void applyMesAllow(StationPanel self, boolean allow) {
|
|
|
if (self == null) {
|
|
|
return;
|
|
|
}
|
|
|
+ if (!mes_allow_enabled) {
|
|
|
+ log.debug("mes-allow-enabled=false,跳过写 L180 allow={} sn={}",
|
|
|
+ Boolean.valueOf(allow), self.getStationSn());
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (allow) {
|
|
|
self.writeMesAllow(true);
|
|
|
return;
|