"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* <バグ修正>2023年6月5日:resetErrorMessageとすべきところをsetErrorMessageとしていた
*/
const app_1 = require("./express/app");
const socketListener_1 = require("./express_socketio/socketListener");
const socketListenerOperation_1 = require("./express_socketio/socketListenerOperation");
const postgres_1 = require("./repository/postgres");
const andonSignalTable_1 = require("./repository/andonSignalTable");
const toyopuc_comm_1 = require("./toyopuc/toyopuc_comm");
const toyopuc_comm_custom_1 = require("./toyopuc/toyopuc_comm_custom");
const andonAnalysisTable_1 = require("./repository/andonAnalysisTable");
const socketServer_1 = require("./express_socketio/socketServer");
const logging_1 = require("./helper/logging");
const timeInformation_1 = require("./helper/timeInformation");
const serverConfig_1 = require("./serverConfig");
/**
*process manager
*
*/
/**
* Expreeアプリケーション起動
* サーバー起動
*/
const app = new app_1.App(serverConfig_1.Config.PORT);
/**
* Socket.io設定
*/
const socketServer = new socketServer_1.SocketServer(app.appServer);
const socketListener_block = new socketListener_1.SocketListener('BlockPC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
const socketListener_head = new socketListener_1.SocketListener('HeadPC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
const socketListener_crank = new socketListener_1.SocketListener('CrankPC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
const socketListener_cam1 = new socketListener_1.SocketListener('Cam1PC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
const socketListener_rod1 = new socketListener_1.SocketListener('Rod1PC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
const socketListener_hsg = new socketListener_1.SocketListener('HsgPC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
//1つの建屋にカムが2組ある場合(例:0機、5機)
const socketListener_cam2 = new socketListener_1.SocketListener('Cam2PC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
//1つの建屋にロッドが2組ある場合(例:0機、5機)
const socketListener_rod2 = new socketListener_1.SocketListener('Rod2PC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
//組付
const socketListener_assembly = new socketListener_1.SocketListener('AssemblyPC', socketServer.io, serverConfig_1.Config.FREQ_Socket);
//管理画面
const socketListener_operation = new socketListenerOperation_1.SocketListener_Operation('Operation', socketServer.io, serverConfig_1.Config.FREQ_Socket);
/**
* データベース接続
*/
const andonDataBase = new postgres_1.Postgres(serverConfig_1.Config.AndonDataBase);
/**
* データベース操作:Webアンドン画面更新用テーブル
*/
const andonSignalTable = new andonSignalTable_1.AndonSignalTable(andonDataBase);
/**
* データベース操作:Webアンドン信号解析用テーブル
*/
(async () => {
const andonAnalysisTable = new andonAnalysisTable_1.AndonAnalysisTable(andonDataBase);
//背景色情報のセット
if (serverConfig_1.Config.bgcolor_master) {
const bgcolor_master = await andonAnalysisTable.select_bgcolor('bgcolor_master');
app.andonAnalysis.set_bgcolor_master(bgcolor_master); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
if (serverConfig_1.Config.bgcolor_master_Call) {
const bgcolor_master_Call = await andonAnalysisTable.select_bgcolor('bgcolor_master_Call');
app.andonAnalysis.set_bgcolor_master_Call(bgcolor_master_Call); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
if (serverConfig_1.Config.bgcolor_master_KARA) {
const bgcolor_master_KARA = await andonAnalysisTable.select_bgcolor('bgcolor_master_KARA');
app.andonAnalysis.set_bgcolor_master_KARA(bgcolor_master_KARA); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
if (serverConfig_1.Config.bgcolor_master_OP1) {
const bgcolor_master_OP1 = await andonAnalysisTable.select_bgcolor('bgcolor_master_OP1');
app.andonAnalysis.set_bgcolor_master_OP1(bgcolor_master_OP1); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
if (serverConfig_1.Config.bgcolor_master_OP2) {
const bgcolor_master_OP2 = await andonAnalysisTable.select_bgcolor('bgcolor_master_OP2');
app.andonAnalysis.set_bgcolor_master_OP2(bgcolor_master_OP2); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
if (serverConfig_1.Config.bgcolor_master_OP3) {
const bgcolor_master_OP3 = await andonAnalysisTable.select_bgcolor('bgcolor_master_OP3');
app.andonAnalysis.set_bgcolor_master_OP3(bgcolor_master_OP3); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
if (serverConfig_1.Config.bgcolor_master_OP4) {
const bgcolor_master_OP4 = await andonAnalysisTable.select_bgcolor('bgcolor_master_OP4');
app.andonAnalysis.set_bgcolor_master_OP4(bgcolor_master_OP4); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
if (serverConfig_1.Config.bgcolor_master_Stock) {
const bgcolor_master_Stock = await andonAnalysisTable.select_bgcolor('bgcolor_master_Stock');
app.andonAnalysis.set_bgcolor_master_Stock(bgcolor_master_Stock); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
//アイコン情報のセット
if (serverConfig_1.Config.icon_master) {
const icon_master = await andonAnalysisTable.select_icon_master();
app.andonAnalysis.set_icon_master(icon_master); //引数が[]の場合はanalysisStopFlag=true(分析処理停止)にする
}
//Html Id情報のセット
if (serverConfig_1.Config.line1blockHtmlIdMaster) {
const line1blockHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line1blockHtmlIdMaster');
app.andonAnalysis.set_line1blockHtmlIdMaster(line1blockHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line2blockHtmlIdMaster) {
const line2blockHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line2blockHtmlIdMaster');
app.andonAnalysis.set_line2blockHtmlIdMaster(line2blockHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line1headHtmlIdMaster) {
const line1headHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line1headHtmlIdMaster');
app.andonAnalysis.set_line1headHtmlIdMaster(line1headHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line2headHtmlIdMaster) {
const line2headHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line2headHtmlIdMaster');
app.andonAnalysis.set_line2headHtmlIdMaster(line2headHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line1crankHtmlIdMaster) {
const line1crankHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line1crankHtmlIdMaster');
app.andonAnalysis.set_line1crankHtmlIdMaster(line1crankHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line2crankHtmlIdMaster) {
const line2crankHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line2crankHtmlIdMaster');
app.andonAnalysis.set_line2crankHtmlIdMaster(line2crankHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line1camHtmlIdMaster) {
const line1camHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line1camHtmlIdMaster');
app.andonAnalysis.set_line1camHtmlIdMaster(line1camHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line2camHtmlIdMaster) {
const line2camHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line2camHtmlIdMaster');
app.andonAnalysis.set_line2camHtmlIdMaster(line2camHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line3camHtmlIdMaster) {
const line3camHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line3camHtmlIdMaster');
app.andonAnalysis.set_line3camHtmlIdMaster(line3camHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line4camHtmlIdMaster) {
const line4camHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line4camHtmlIdMaster');
app.andonAnalysis.set_line4camHtmlIdMaster(line4camHtmlIdMaster);
}
//Html Id情報のセット
if (serverConfig_1.Config.line1assemblyHtmlIdMaster) {
const line1assemblyHtmlIdMaster = await andonAnalysisTable.select_html_id_master('line1assemblyHtmlIdMaster');
app.andonAnalysis.set_line1assemblyHtmlIdMaster(line1assemblyHtmlIdMaster);
}
app.andonAnalysis.getAndonDataByCreatedAt = async (requestBody) => {
let res = await andonSignalTable.selectByCreatedAt(requestBody);
return res;
};
})();
/**
* toyopuc接続・データ読み出し
*/
const toyopuc_line1block = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Block1PORT, serverConfig_1.Config.Block1IP), 'line1block.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Block1Usage);
const toyopuc_line2block = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Block2PORT, serverConfig_1.Config.Block2IP), 'line2block.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Block2Usage);
const toyopuc_line1head = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Head1PORT, serverConfig_1.Config.Head1IP), 'line1head.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Head1Usage);
const toyopuc_line2head = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Head2PORT, serverConfig_1.Config.Head2IP), 'line2head.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Head2Usage);
const toyopuc_line1crank = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Crank1PORT, serverConfig_1.Config.Crank1IP), 'line1crank.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Crank1Usage);
const toyopuc_line2crank = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Crank2PORT, serverConfig_1.Config.Crank2IP), 'line2crank.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Crank2Usage);
const toyopuc_line1cam = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Cam1PORT, serverConfig_1.Config.Cam1IP), 'line1cam.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Cam1Usage);
const toyopuc_line2cam = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Cam2PORT, serverConfig_1.Config.Cam2IP), 'line2cam.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Cam2Usage);
const toyopuc_line3cam = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Cam3PORT, serverConfig_1.Config.Cam3IP), 'line3cam.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Cam3Usage);
const toyopuc_line4cam = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Cam4PORT, serverConfig_1.Config.Cam4IP), 'line4cam.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Cam4Usage);
const toyopuc_line1rod = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Rod1PORT, serverConfig_1.Config.Rod1IP), 'line1rod.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Rod1Usage);
const toyopuc_line2rod = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Rod2PORT, serverConfig_1.Config.Rod2IP), 'line2rod.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Rod2Usage);
const toyopuc_line1hsg = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Hsg1PORT, serverConfig_1.Config.Hsg1IP), 'line1hsg.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Hsg1Usage);
const toyopuc_line1assembly = new toyopuc_comm_custom_1.ToyopucComm_custom(new toyopuc_comm_1.ToyopucComm(serverConfig_1.Config.Assembly1PORT, serverConfig_1.Config.Assembly1IP), 'line1assembly.csv', serverConfig_1.Config.FREQ_PLC, serverConfig_1.Config.Assembly1Usage);
socketListener_operation.plcRestart = (tableName) => {
if (tableName == 'line1block') {
toyopuc_line1block.setStopFlag(false);
toyopuc_line1block.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line2block') {
toyopuc_line2block.setStopFlag(false);
toyopuc_line2block.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line1head') {
toyopuc_line1head.setStopFlag(false);
toyopuc_line1head.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line2head') {
toyopuc_line2head.setStopFlag(false);
toyopuc_line2head.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line1crank') {
toyopuc_line1crank.setStopFlag(false);
toyopuc_line1crank.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line2crank') {
toyopuc_line2crank.setStopFlag(false);
toyopuc_line2crank.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line1cam') {
toyopuc_line1cam.setStopFlag(false);
toyopuc_line1cam.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line2cam') {
toyopuc_line2cam.setStopFlag(false);
toyopuc_line2cam.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line3cam') {
toyopuc_line3cam.setStopFlag(false);
toyopuc_line3cam.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line4cam') {
toyopuc_line4cam.setStopFlag(false);
toyopuc_line4cam.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line1rod') {
toyopuc_line1rod.setStopFlag(false);
toyopuc_line1rod.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line2rod') {
toyopuc_line2rod.setStopFlag(false);
toyopuc_line2rod.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line1hsg') {
toyopuc_line1hsg.setStopFlag(false);
toyopuc_line1hsg.toyopucRestart('Operation画面による再起動操作');
}
if (tableName == 'line1assembly') {
toyopuc_line1assembly.setStopFlag(false);
toyopuc_line1assembly.toyopucRestart('Operation画面による再起動操作');
}
};
socketListener_operation.plcStop = (tableName) => {
if (tableName == 'line1block') {
toyopuc_line1block.setStopFlag(true);
toyopuc_line1block.toyopucStop('Operation画面による停止操作');
}
if (tableName == 'line2block') {
toyopuc_line2block.setStopFlag(true);
toyopuc_line2block.toyopucStop('Operation画面による停止操作');
}
if (tableName == 'line1head') {
toyopuc_line1head.setStopFlag(true);
toyopuc_line1head.toyopucStop('Operation画面による停止操作');
}
if (tableName == 'line2head') {
toyopuc_line2head.setStopFlag(true);
toyopuc_line2head.toyopucStop('Operation画面による停止操作');
}
if (tableName == 'line1crank') {
toyopuc_line1crank.setStopFlag(true);
toyopuc_line1crank.toyopucStop('Operation画面による停止操作');
}
if (tableName == 'line2crank') {
toyopuc_line2crank.setStopFlag(true);
toyopuc_line2crank.toyopucStop('Operation画面による停止操作');
}
if (tableName == 'line1cam') {
toyopuc_line1cam.setStopFlag(true);
toyopuc_line1cam.toyopucStop('Operation画面による再起動操作');
}
if (tableName == 'line2cam') {
toyopuc_line2cam.setStopFlag(true);
toyopuc_line2cam.toyopucStop('Operation画面による再起動操作');
}
if (tableName == 'line3cam') {
toyopuc_line3cam.setStopFlag(true);
toyopuc_line3cam.toyopucStop('Operation画面による再起動操作');
}
if (tableName == 'line4cam') {
toyopuc_line4cam.setStopFlag(true);
toyopuc_line4cam.toyopucStop('Operation画面による再起動操作');
}
if (tableName == 'line1rod') {
toyopuc_line1rod.setStopFlag(true);
toyopuc_line1rod.toyopucStop('Operation画面による再起動操作');
}
if (tableName == 'line2rod') {
toyopuc_line2rod.setStopFlag(true);
toyopuc_line2rod.toyopucStop('Operation画面による再起動操作');
}
if (tableName == 'line1hsg') {
toyopuc_line1hsg.setStopFlag(true);
toyopuc_line1hsg.toyopucStop('Operation画面による再起動操作');
}
if (tableName == 'line1assembly') {
toyopuc_line1assembly.setStopFlag(true);
toyopuc_line1assembly.toyopucStop('Operation画面による再起動操作');
}
};
/**
* メインインターバル設定
* インターバル停止条件:
*/
let count_checkFreq = 1;
let count_stopDbInsert = 1;
let deleteFlag = false;
let clientsOfBlock = 0;
let clientsOfHead = 0;
let clientsOfCrank = 0;
let clientsOfCam1 = 0;
let clientsOfCam2 = 0;
let clientsOfRod1 = 0;
let clientsOfRod2 = 0;
let clientsOfHsg = 0;
let clientsOfAssembly = 0;
logging_1.Logging.initializeConnectingDevice(); //サーバー起動時にWebアンドン利用者掲載のJSONを初期化//在服务器启动时初始化Web Andon用户发布的JSON
let mainInterval = setInterval(async () => {
if (serverConfig_1.Config.Block1Usage == 'use') {
if (toyopuc_line1block.isConnected()) {
//アンドン最新値セット(socket.io用)//安东最新值集(socket.io用)
socketListener_block.setAndonData('L1', toyopuc_line1block.latest.data);
//アンドン最新値セット(2023年5月時点用途なし)//安东最新值集(2023年5月无用途)
app.andonAnalysis.setAndonData('line1block', toyopuc_line1block.latest);
//アンドン最新値INSERT(データベース用)
andonSignalTable.insertLatest('line1block', toyopuc_line1block.latest);
//PLC状態セット(socket.io用)
socketListener_operation.setPlcCRunningMode('line1block', 'good');
socketListener_block.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Block1);
}
else {
socketListener_operation.setPlcCRunningMode('line1block', 'plc_disconnect');
socketListener_block.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Block1);
}
}
if (serverConfig_1.Config.Block2Usage == 'use') {
if (toyopuc_line2block.isConnected()) {
socketListener_block.setAndonData('L2', toyopuc_line2block.latest.data);
app.andonAnalysis.setAndonData('line2block', toyopuc_line2block.latest);
andonSignalTable.insertLatest('line2block', toyopuc_line2block.latest);
socketListener_operation.setPlcCRunningMode('line2block', 'good');
socketListener_block.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Block2);
}
else {
socketListener_operation.setPlcCRunningMode('line2block', 'plc_disconnect');
socketListener_block.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Block2);
}
}
if (serverConfig_1.Config.Head1Usage == 'use') {
if (toyopuc_line1head.isConnected()) {
socketListener_head.setAndonData('L1', toyopuc_line1head.latest.data);
app.andonAnalysis.setAndonData('line1head', toyopuc_line1head.latest);
andonSignalTable.insertLatest('line1head', toyopuc_line1head.latest);
socketListener_operation.setPlcCRunningMode('line1head', 'good');
socketListener_head.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Head1);
}
else {
socketListener_operation.setPlcCRunningMode('line1head', 'plc_disconnect');
socketListener_head.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Head1);
}
}
if (serverConfig_1.Config.Head2Usage == 'use') {
if (toyopuc_line2head.isConnected()) {
socketListener_head.setAndonData('L2', toyopuc_line2head.latest.data);
app.andonAnalysis.setAndonData('line2head', toyopuc_line2head.latest);
andonSignalTable.insertLatest('line2head', toyopuc_line2head.latest);
socketListener_operation.setPlcCRunningMode('line2head', 'good');
socketListener_head.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Head2);
}
else {
socketListener_operation.setPlcCRunningMode('line2head', 'plc_disconnect');
socketListener_head.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Head2);
}
}
if (serverConfig_1.Config.Crank1Usage == 'use') {
if (toyopuc_line1crank.isConnected()) {
socketListener_crank.setAndonData('L1', toyopuc_line1crank.latest.data);
app.andonAnalysis.setAndonData('line1crank', toyopuc_line1crank.latest);
andonSignalTable.insertLatest('line1crank', toyopuc_line1crank.latest);
socketListener_operation.setPlcCRunningMode('line1crank', 'good');
socketListener_crank.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Crank1);
}
else {
socketListener_operation.setPlcCRunningMode('line1crank', 'plc_disconnect');
socketListener_crank.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Crank1);
}
}
if (serverConfig_1.Config.Crank2Usage == 'use') {
if (toyopuc_line2crank.isConnected()) {
socketListener_crank.setAndonData('L2', toyopuc_line2crank.latest.data);
app.andonAnalysis.setAndonData('line2crank', toyopuc_line2crank.latest);
andonSignalTable.insertLatest('line2crank', toyopuc_line2crank.latest);
socketListener_operation.setPlcCRunningMode('line2crank', 'good');
socketListener_crank.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Crank2);
}
else {
socketListener_operation.setPlcCRunningMode('line2crank', 'plc_disconnect');
socketListener_crank.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Crank2);
}
}
if (serverConfig_1.Config.Cam1Usage == 'use') {
if (toyopuc_line1cam.isConnected()) {
socketListener_cam1.setAndonData('L1', toyopuc_line1cam.latest.data);
app.andonAnalysis.setAndonData('line1cam', toyopuc_line1cam.latest);
andonSignalTable.insertLatest('line1cam', toyopuc_line1cam.latest);
socketListener_operation.setPlcCRunningMode('line1cam', 'good');
socketListener_cam1.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam1);
}
else {
socketListener_operation.setPlcCRunningMode('line1cam', 'plc_disconnect');
socketListener_cam1.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam1);
}
}
if (serverConfig_1.Config.Cam2Usage == 'use') {
if (toyopuc_line2cam.isConnected()) {
socketListener_cam1.setAndonData('L2', toyopuc_line2cam.latest.data);
app.andonAnalysis.setAndonData('line2cam', toyopuc_line2cam.latest);
andonSignalTable.insertLatest('line2cam', toyopuc_line2cam.latest);
socketListener_operation.setPlcCRunningMode('line2cam', 'good');
socketListener_cam1.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam2);
}
else {
socketListener_operation.setPlcCRunningMode('line2cam', 'plc_disconnect');
socketListener_cam1.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam2);
}
}
if (serverConfig_1.Config.Cam3Usage == 'use') {
if (toyopuc_line3cam.isConnected()) {
socketListener_cam2.setAndonData('L1', toyopuc_line3cam.latest.data);
app.andonAnalysis.setAndonData('line3cam', toyopuc_line3cam.latest);
andonSignalTable.insertLatest('line3cam', toyopuc_line3cam.latest);
socketListener_operation.setPlcCRunningMode('line3cam', 'good');
socketListener_cam2.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam3);
}
else {
socketListener_operation.setPlcCRunningMode('line3cam', 'plc_disconnect');
socketListener_cam2.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam3);
}
}
if (serverConfig_1.Config.Cam4Usage == 'use') {
if (toyopuc_line4cam.isConnected()) {
socketListener_cam2.setAndonData('L2', toyopuc_line4cam.latest.data);
app.andonAnalysis.setAndonData('line4cam', toyopuc_line4cam.latest);
andonSignalTable.insertLatest('line4cam', toyopuc_line4cam.latest);
socketListener_operation.setPlcCRunningMode('line4cam', 'good');
socketListener_cam2.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam4);
}
else {
socketListener_operation.setPlcCRunningMode('line4cam', 'plc_disconnect');
socketListener_cam2.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Cam4);
}
}
if (serverConfig_1.Config.Rod1Usage == 'use') {
if (toyopuc_line1rod.isConnected()) {
socketListener_rod1.setAndonData('L1', toyopuc_line1rod.latest.data);
app.andonAnalysis.setAndonData('line1rod', toyopuc_line1rod.latest);
andonSignalTable.insertLatest('line1rod', toyopuc_line1rod.latest);
socketListener_operation.setPlcCRunningMode('line1rod', 'good');
socketListener_rod1.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Rod1);
}
else {
socketListener_operation.setPlcCRunningMode('line1rod', 'plc_disconnect');
socketListener_rod1.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Rod1);
}
}
if (serverConfig_1.Config.Rod2Usage == 'use') {
if (toyopuc_line2rod.isConnected()) {
socketListener_rod2.setAndonData('L1', toyopuc_line2rod.latest.data);
app.andonAnalysis.setAndonData('line2rod', toyopuc_line2rod.latest);
andonSignalTable.insertLatest('line2rod', toyopuc_line2rod.latest);
socketListener_operation.setPlcCRunningMode('line2rod', 'good');
socketListener_rod2.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Rod2);
}
else {
socketListener_operation.setPlcCRunningMode('line2rod', 'plc_disconnect');
socketListener_rod2.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Rod2);
}
}
// if (serverConfig_1.Config.Hsg1Usage == 'use') {
// if (toyopuc_line1hsg.isConnected()) {
// socketListener_hsg.setAndonData('L1', toyopuc_line1hsg.latest.data);
// app.andonAnalysis.setAndonData('line1rod', toyopuc_line1hsg.latest);
// andonSignalTable.insertLatest('line1rod', toyopuc_line1hsg.latest);
// socketListener_operation.setPlcCRunningMode('line1rod', 'good');
// socketListener_hsg.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Assembly1);
// }
// else {
// socketListener_operation.setPlcCRunningMode('line1rod', 'plc_disconnect');
// socketListener_hsg.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Assembly1);
// }
// }
//新增/////////////////////////////////////////////////////////////////////////////////////////增加后大象数据库有数据
if (serverConfig_1.Config.Hsg1Usage == 'use') {
if (toyopuc_line1hsg.isConnected()) {
socketListener_hsg.setAndonData('L1', toyopuc_line1hsg.latest.data);
app.andonAnalysis.setAndonData('line1hsg', toyopuc_line1hsg.latest);
andonSignalTable.insertLatest('line1hsg', toyopuc_line1hsg.latest);
socketListener_operation.setPlcCRunningMode('line1hsg', 'good');
socketListener_hsg.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Assembly1);
}
else {
socketListener_operation.setPlcCRunningMode('line1hsg', 'plc_disconnect');
socketListener_hsg.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Assembly1);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
if (serverConfig_1.Config.Assembly1Usage == 'use') {
if (toyopuc_line1assembly.isConnected()) {
socketListener_assembly.setAndonData('L1', toyopuc_line1assembly.latest.data);
app.andonAnalysis.setAndonData('line1assembly', toyopuc_line1assembly.latest);
andonSignalTable.insertLatest('line1assembly', toyopuc_line1assembly.latest);
socketListener_operation.setPlcCRunningMode('line1assembly', 'good');
socketListener_assembly.resetErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Assembly1);
}
else {
socketListener_operation.setPlcCRunningMode('line1assembly', 'plc_disconnect');
socketListener_assembly.setErrorMessage(serverConfig_1.Config.Msg_PLC_fail_Assembly1);
}
}
//XX回に1回のペースで行う
if (count_checkFreq >= serverConfig_1.Config.FREQ_PLC_check / serverConfig_1.Config.FREQ_Main) {
//INSERT処理が閾値以内の頻度で完了しているか?
if (serverConfig_1.Config.Block1Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line1block'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line1block', 'freq_error');
//PLC再起動処理
toyopuc_line1block.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line1block', 'good');
}
}
if (serverConfig_1.Config.Block2Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line2block'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line2block', 'freq_error');
//PLC再起動処理
toyopuc_line2block.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line2block', 'good');
}
}
if (serverConfig_1.Config.Head1Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line1head'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line1head', 'freq_error');
//PLC再起動処理
toyopuc_line1head.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line1head', 'good');
}
}
if (serverConfig_1.Config.Head2Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line2head'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line2head', 'freq_error');
//PLC再起動処理
toyopuc_line2head.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line2head', 'good');
}
}
if (serverConfig_1.Config.Crank1Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line1crank'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line1crank', 'freq_error');
//PLC再起動処理
toyopuc_line1crank.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line1crank', 'good');
}
}
if (serverConfig_1.Config.Crank2Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line2crank'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line2crank', 'freq_error');
//PLC再起動処理
toyopuc_line2crank.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line2crank', 'good');
}
}
if (serverConfig_1.Config.Cam1Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line1cam'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line1cam', 'freq_error');
//PLC再起動処理
toyopuc_line1cam.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line1cam', 'good');
}
}
if (serverConfig_1.Config.Cam2Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line2cam'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line2cam', 'freq_error');
//PLC再起動処理
toyopuc_line2cam.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line2cam', 'good');
}
}
if (serverConfig_1.Config.Cam3Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line3cam'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line3cam', 'freq_error');
//PLC再起動処理
toyopuc_line3cam.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line3cam', 'good');
}
}
if (serverConfig_1.Config.Cam4Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line4cam'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line4cam', 'freq_error');
//PLC再起動処理
toyopuc_line4cam.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line4cam', 'good');
}
}
if (serverConfig_1.Config.Rod1Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line1rod'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line1rod', 'freq_error');
//PLC再起動処理
toyopuc_line1rod.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line1rod', 'good');
}
}
if (serverConfig_1.Config.Rod2Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line2rod'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line2rod', 'freq_error');
//PLC再起動処理
toyopuc_line2rod.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line2rod', 'good');
}
}
if (serverConfig_1.Config.Hsg1Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line1hsg'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line1hsg', 'freq_error');
//PLC再起動処理
toyopuc_line1hsg.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line1hsg', 'good');
}
}
if (serverConfig_1.Config.Assembly1Usage == 'use') {
if (!(await andonSignalTable.checkFrequencyOfInsert(serverConfig_1.Config.FREQ_Database_check, 'line1assembly'))) {
//PLC状態セット(socket.io用)
socketListener_operation.setDatabaseRunningMode('line1assembly', 'freq_error');
//PLC再起動処理
toyopuc_line1assembly.toyopucRestart('PLCだんまりリセットのための再起動');
}
else {
socketListener_operation.setDatabaseRunningMode('line1assembly', 'good');
}
}
count_checkFreq = 1;
}
else {
count_checkFreq++;
}
//XX回に1回のペースで行う
if (count_stopDbInsert >= serverConfig_1.Config.FREQ_Time_check / serverConfig_1.Config.FREQ_Main) {
//計画停止時刻の刻範囲か?
if (timeInformation_1.TimeInformation.isInTargetTime(serverConfig_1.Config.Time_Database_Stop, serverConfig_1.Config.Time_Database_Restart)) {
if (!deleteFlag) {
logging_1.Logging.writeSystemLog('定刻処理:PLC収集停止');
//PLC接続停止準備
toyopuc_line1block.setStopFlag(true);
toyopuc_line2block.setStopFlag(true);
toyopuc_line1head.setStopFlag(true);
toyopuc_line2head.setStopFlag(true);
toyopuc_line1crank.setStopFlag(true);
toyopuc_line2crank.setStopFlag(true);
toyopuc_line1cam.setStopFlag(true);
toyopuc_line2cam.setStopFlag(true);
toyopuc_line3cam.setStopFlag(true);
toyopuc_line4cam.setStopFlag(true);
toyopuc_line1rod.setStopFlag(true);
toyopuc_line2rod.setStopFlag(true);
toyopuc_line1hsg.setStopFlag(true);
toyopuc_line1assembly.setStopFlag(true);
//PLC接続を停止
toyopuc_line1block.toyopucStop('運転停止期間に入ります');
toyopuc_line2block.toyopucStop('運転停止期間に入ります');
toyopuc_line1head.toyopucStop('運転停止期間に入ります');
toyopuc_line2head.toyopucStop('運転停止期間に入ります');
toyopuc_line1crank.toyopucStop('運転停止期間に入ります');
toyopuc_line2crank.toyopucStop('運転停止期間に入ります');
toyopuc_line1cam.toyopucStop('運転停止期間に入ります');
toyopuc_line2cam.toyopucStop('運転停止期間に入ります');
toyopuc_line3cam.toyopucStop('運転停止期間に入ります');
toyopuc_line4cam.toyopucStop('運転停止期間に入ります');
toyopuc_line1rod.toyopucStop('運転停止期間に入ります');
toyopuc_line2rod.toyopucStop('運転停止期間に入ります');
toyopuc_line1hsg.toyopucStop('運転停止期間に入ります');
toyopuc_line1assembly.toyopucStop('運転停止期間に入ります');
//XX日前までのデータをDBから削除
if (serverConfig_1.Config.Block1Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line1block');
}
if (serverConfig_1.Config.Block2Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line2block');
}
if (serverConfig_1.Config.Head1Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line1head');
}
if (serverConfig_1.Config.Head2Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line2head');
}
if (serverConfig_1.Config.Crank1Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line1crank');
}
if (serverConfig_1.Config.Crank2Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line2crank');
}
if (serverConfig_1.Config.Cam1Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line1cam');
}
if (serverConfig_1.Config.Cam2Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line2cam');
}
if (serverConfig_1.Config.Cam3Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line3cam');
}
if (serverConfig_1.Config.Cam4Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line4cam');
}
if (serverConfig_1.Config.Rod1Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line1rod');
}
if (serverConfig_1.Config.Rod2Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line2rod');
}
if (serverConfig_1.Config.Hsg1Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line1hsg');
}
if (serverConfig_1.Config.Assembly1Usage == 'use') {
await andonSignalTable.deleteByCreatedAt(serverConfig_1.Config.Delete_target, 'line1assembly');
}
//XX日前までのログを削除
logging_1.Logging.deleteSystemLog(serverConfig_1.Config.Delete_target);
logging_1.Logging.deleteErrorLog(serverConfig_1.Config.Delete_target);
deleteFlag = true;
}
}
else {
if (deleteFlag) {
logging_1.Logging.writeSystemLog('定刻処理:PLC収集再開');
//PLC接続再開準備
toyopuc_line1block.setStopFlag(false);
toyopuc_line2block.setStopFlag(false);
toyopuc_line1head.setStopFlag(false);
toyopuc_line2head.setStopFlag(false);
toyopuc_line1crank.setStopFlag(false);
toyopuc_line2crank.setStopFlag(false);
toyopuc_line1cam.setStopFlag(false);
toyopuc_line2cam.setStopFlag(false);
toyopuc_line3cam.setStopFlag(false);
toyopuc_line4cam.setStopFlag(false);
toyopuc_line1rod.setStopFlag(false);
toyopuc_line2rod.setStopFlag(false);
toyopuc_line1hsg.setStopFlag(false);
toyopuc_line1assembly.setStopFlag(false);
//PLC接続
toyopuc_line1block.toyopucRestart('運転停止期間の終了');
toyopuc_line2block.toyopucRestart('運転停止期間の終了');
toyopuc_line1head.toyopucRestart('運転停止期間の終了');
toyopuc_line2head.toyopucRestart('運転停止期間の終了');
toyopuc_line1crank.toyopucRestart('運転停止期間の終了');
toyopuc_line2crank.toyopucRestart('運転停止期間の終了');
toyopuc_line1cam.toyopucRestart('運転停止期間の終了');
toyopuc_line2cam.toyopucRestart('運転停止期間の終了');
toyopuc_line3cam.toyopucRestart('運転停止期間の終了');
toyopuc_line4cam.toyopucRestart('運転停止期間の終了');
toyopuc_line1rod.toyopucRestart('運転停止期間の終了');
toyopuc_line2rod.toyopucRestart('運転停止期間の終了');
toyopuc_line1hsg.toyopucRestart('運転停止期間の終了');
toyopuc_line1assembly.toyopucRestart('運転停止期間の終了');
deleteFlag = false;
}
}
count_stopDbInsert = 1;
}
else {
count_stopDbInsert++;
}
//利用者数
clientsOfBlock = socketListener_block.getClientCount();
socketListener_operation.setUserInfo('BlockPC', clientsOfBlock);
//利用者数
clientsOfHead = socketListener_head.getClientCount();
socketListener_operation.setUserInfo('HeadPC', clientsOfHead);
//利用者数
clientsOfCrank = socketListener_crank.getClientCount();
socketListener_operation.setUserInfo('CrankPC', clientsOfCrank);
//利用者数
clientsOfCam1 = socketListener_cam1.getClientCount();
socketListener_operation.setUserInfo('Cam1PC', clientsOfCam1);
//利用者数
clientsOfCam2 = socketListener_cam1.getClientCount();
socketListener_operation.setUserInfo('Cam1PC', clientsOfCam2);
//利用者数
clientsOfRod1 = socketListener_rod1.getClientCount();
socketListener_operation.setUserInfo('Rod1PC', clientsOfRod1);
//利用者数
clientsOfRod2 = socketListener_rod2.getClientCount();
socketListener_operation.setUserInfo('Rod2PC', clientsOfRod2);
//利用者数
clientsOfHsg = socketListener_hsg.getClientCount();
socketListener_operation.setUserInfo('HsgPC', clientsOfHsg);
//利用者数
clientsOfAssembly = socketListener_assembly.getClientCount();
socketListener_operation.setUserInfo('AssemblyPC', clientsOfAssembly);
socketListener_operation.setAnalysisCount(app.getAnalysisCount());
//カウントを初期化
if (timeInformation_1.TimeInformation.isInTargetTime('04:00', '04:30')) {
app.initializeAnalysisCount();
}
}, serverConfig_1.Config.FREQ_Main);
最新发布