// Use this for initialization void Start() { // Sets the main DayNight handler. if (Handler != null && Handler != this) { Destroy(gameObject); } else if (Handler == null) { Handler = this; } // Sets the proper cycle duration for each of the 4 phases cycleUpdate = cycleTime / 4; // Creates new lists to store all the renderer variables. AnimatedSprites = new List <MeshRenderer>(); StaticSprites = new List <MeshRenderer>(); MiscRenderers = new List <Renderer>(); // Creates the proper colors for the screen darkening effect. scrnDay = new Color(0, 0, 0, day.a); scrnDusk = new Color(0, 0, 0, dusk.a); scrnNight = new Color(0, 0, 0, night.a); scrnDawn = new Color(0, 0, 0, dawn.a); // Resets the default colors' alpha to 255. day = new Color(day.r, day.g, day.b, 1); dusk = new Color(dusk.r, dusk.g, dusk.b, 1); night = new Color(night.r, night.g, night.b, 1); dawn = new Color(dawn.r, dawn.g, dawn.b, 1); // Gets the image needed for the darkening effect. screenDark = GetComponentInChildren <Image>(); // Jumps to the specified starting cycle. JumpToCycle(startingCycle); // Starts the delay and the static updates. StartCoroutine("StartDelay"); InvokeRepeating("UpdateStatic", cycleStartDelay, staticUpdateFreq); }
/// <summary> /// Event when PLC reach the End of the main Cycle, this will be called, whenever the Controller reaches the end of cycle. /// </summary> /// <param name="in_Sender">PLC which fired this event</param> /// <param name="in_ErrorCode">ErrorCode of Runtime of the PLC</param> /// <param name="in_DateTime">DateTime when the configuration changed</param> /// <param name="in_CycleTime_ns">current cycle time in ns of the PLC</param> /// <param name="in_CycleCount">current count of Cycles of the PLC</param> void instance_OnEndOfCycle(IInstance in_Sender, ERuntimeErrorCode in_ErrorCode, DateTime in_DateTime, long in_CycleTime_ns, uint in_CycleCount) { if (IsConfigured) { NewCycle?.Invoke(); //try //{ // // Read outputs of the virtual controller and assign to variables of the Co-Simulation // coSimulation.setOnBeltActive = instance.ReadBool("setOnBeltActive"); // coSimulation.moveBeltActive = instance.ReadBool("moveBeltActive"); // coSimulation.setOffBeltActive = instance.ReadBool("setOffBeltActive"); // coSimulation.releaseActive = instance.ReadBool("releaseActive"); // coSimulation.acknowledgeActive = instance.ReadBool("acknowledgeActive"); // coSimulation.restartActive = instance.ReadBool("restartActive"); // // Call the Co-Simulation programm // coSimulation.CoSimProgramm(); // // Write the Co-Simulation values to the inputs of the virtual controller // instance.WriteBool("sensorStartPos", coSimulation.sensorStartPos); // instance.WriteBool("sensorBeltStart", coSimulation.sensorBeltStart); // instance.WriteBool("sensorBeltDest", coSimulation.sensorBeltDest); // instance.WriteBool("sensorEndPos", coSimulation.sensorEndPos); //} //catch (Exception ex) //{ //} } else { try { instance.UpdateTagList(ETagListDetails.IO); IsConfigured = true; } catch (Exception ex) { } } }