package promauto.jroboplc.roboplant;
import static org.junit.Assert.*;
import org.junit.Test;
import promauto.jroboplc.JRoboUtils;
import promauto.jroboplc.Module;
import promauto.jroboplc.Tag;
public class SeqEntryTest {
@Test
public void test() {
System.out.println("\n\n\n===== SeqEntryTest");
Module m0 = new Module();
m0.moduleName = "mod0";
try {
JRoboUtils.clearModules();
JRoboUtils.addModules(m0);
} catch (Exception e) {
}
Tag tagInput = m0.tagTable.createTag("MCHB_111_Input", 0);
Tag tagMasterout = m0.tagTable.createTag("MCHB_111_Masterout", 0);
Tag tagSusp = m0.tagTable.createTag("MCHB_111_Susp", 0);
Tag tagA1 = m0.tagTable.createTag("A1", 0);
Tag tagA2 = m0.tagTable.createTag("A2", 0);
Tag tagB1 = m0.tagTable.createTag("B1", 0);
SeqEntry m = new SeqEntry(m0, "111", "test seq entry for 111");
m.setTime(2,1);
m.setDeviceInputTag(tagInput, 1, 0);
m.setDeviceStateTag(tagMasterout, 1);
m.setDeviceSuspTag(tagSusp, 1);
m.addControlTag(tagA1, 1);
m.addControlTag(tagA2, 1);
m.addControlTagGroup();
m.addControlTag(tagB1, 1);
Integer cntOn = -1;
Integer cntOff = -1;
m.execute(cntOn, cntOff);
assertEquals(m.tagInput.getName(), "111_Input");
assertEquals(m.tagOutput.getName(), "111_Output");
assertEquals(m.tagTimeStart.getName(), "111_TimeStart");
assertEquals(m.tagTimeStop.getName(), "111_TimeStop");
assertEquals(m.tagInput.get(), 0);
assertEquals(m.tagOutput.get(), 0);
assertEquals(m.tagTimeStart.get(), 2);
assertEquals(m.tagTimeStop.get(), 1);
assertEquals(m.tagDeviceInput.get(), 0);
assertEquals(m.tagDeviceState.get(), 0);
assertEquals(m.tagDeviceSusp.get(), 0);
assertEquals(m.tagsControl.size(), 2);
m.execute(2,1);
assertEquals(m.tagInput.get(), 0);
assertEquals(m.tagOutput.get(), 0);
assertEquals(m.tagDeviceInput.get(), 0);
assertEquals(m.tagDeviceState.get(), 0);
tagA1.set(1);
m.execute(3,3);
assertEquals(m.tagInput.get(), 0);
assertEquals(m.tagOutput.get(), 0);
assertEquals(m.tagDeviceInput.get(), 0);
assertEquals(m.tagDeviceState.get(), 0);
tagA2.set(1);
m.execute();
assertEquals(m.tagInput.get(), 1);
assertEquals(m.tagOutput.get(), 0);
assertEquals(m.tagDeviceInput.get(), 1);
assertEquals(m.tagDeviceState.get(), 0);
tagMasterout.set(1);
m.execute();
assertEquals(m.tagInput.get(), 1);
assertEquals(m.tagOutput.get(), 1);
assertEquals(m.tagDeviceInput.get(), 1);
assertEquals(m.tagDeviceState.get(), 1);
m.execute(3,0);
assertEquals(m.tagInput.get(), 0);
assertEquals(m.tagOutput.get(), 0);
assertEquals(m.tagDeviceInput.get(), 0);
assertEquals(m.tagDeviceState.get(), 1);
tagA1.set(0);
m.execute(2,2);
assertEquals(m.tagInput.get(), 0);
tagB1.set(1);
m.execute();
assertEquals(m.tagInput.get(), 1);
tagSusp.set(1);
m.execute();
assertEquals(m.getDeviceSusp(), true);
tagSusp.set(0);
m.execute();
}
}