import { ipcRenderer } from "electron";

export const SET_PLC_IPADDRESS = "SET_PLC_IPADDRESS";
export const INITIALIZE_PLC = "INITIALIZE_PLC";
export const PLC_DATA_RECEIVED = "PLC_DATA_RECEIVED";
export const PLC_ERROR_RECEIVED = "PLC_ERROR_RECEIVED";


export function setPlcIpAddress(ipAddress){
	return {
		type: SET_PLC_IPADDRESS,
		payload: ipAddress
	};
}

export function ipcPlcInitializeSend(ipAddress, tagList){
	ipcRenderer.send("plc:initialize", ipAddress, tagList);
	return {
		type: INITIALIZE_PLC,
		payload: true
	};
}

export function ipcPlcDetailsReceived(event, plcData){
	return {
		type: PLC_DATA_RECEIVED,
		payload: plcData
	};
}

export function ipcPlcErrorReceived(event, plcError){
	return {
		type: PLC_ERROR_RECEIVED,
		payload: plcError
	};
}

