GRAPHIC: New Entity Operations™ Alpha Logo

EntityScript



core_transmitter





# -*- coding: utf-8 -*-
"""
COPYRIGHT (C) 2020-2023 NEW ENTITY OPERATIONS INC. ALL RIGHTS RESERVED
INSTANCE: core_transmitter
MODIFIED: 2023/05/15
OVERVIEW: Make the MODE instance discoverable to initializing parsers

core_transmitter takes I/O tasks and turns them into phase based threads

This is the example simulation

"""
__version__ = "0.0.5"
__author__ = "Ryan McKenna"
__copyright__ = "Copyright (C) 2023 New Entity Operations Inc."
__credits__ = [
 "Ryan McKenna",
 "New Entity Operations Inc.", "New Entity Operations, LLC"]
__email__ = "Operator@NewEntityOperations.com"
__license__ = "New Entity License"
__maintainer__ = "Ryan McKenna"
__status__ = "Production"

## MODE-> facilities
from MODE.facilities import (defaultdict, PATH_INSTANCE, TemporaryFile)

from core_middlelayer import (CURRENT_FULLES, DIRDATA, TEMP_FULLES)

## Add instance: Empty
a = 0

## clock section
clock_now = 0
clock_then = 0

## phase_que
text_now = 'Hello, text now'
text_in_que = ', Hello, sim que'
sim_id = "SIMID: TRIAL000000001"

## usermask simulated values
usermask_1 = 'VCNKEYTEST00000001'
usermask_2 = 'VCNKEYTEST00000002'
usermask_3 = 'VCNKEYTEST00000003'
usermask_4 = 'VCNKEYTEST00000004'
usermask_5 = 'VCNKEYTEST00000005'
usermask_6 = 'VCNKEYTEST00000006'
usermask_7 = 'VCNKEYTEST00000007'
usermask_8 = 'VCNKEYTEST00000008'

## Instance: New
NEW_INSTANCE = "New Instance"

## skip: sim
SKIP_SIM = "XXXXXDDDD"

## PHASE_INSTANCE: Requires special clear
PHASE_INSTANCE = []

## INSTANCE_MESSAGE: Temp
INSTANCE_MESSAGE = [NEW_INSTANCE]

## Add a manifest of messages: Temp
manifest = []

## Last tempo instance
TEMP_INSTANCE_LAST = []

class STATE:
 ## Instance now
 INSTANCE_NOW = 0

class PhaseReceiver:
 def __init__(self):
  class phase:
   try:
     __text__ = manifest[-1]
   ## First instance run
   except IndexError:
     try:
      __text__ = INSTANCE_MESSAGE[0]
      INSTANCE_MESSAGE.clear()
     except:
      __text__ = SKIP_SIM

  def construct():
   print("manifest: "+str(manifest))
   print("INSTANCE_MESSAGE: "+str(INSTANCE_MESSAGE))
   print("PHASE_INSTANCE: "+str(PHASE_INSTANCE))
   INSTANCE_NOW = 0
   ## Provide a start position new instance initializer
   if phase.__text__ == NEW_INSTANCE:
    PHASE_INSTANCE.append(phase.__text__)
   ## Provide a default skip code if the state is in a waiting period
   elif phase.__text__ == SKIP_SIM:
    pass
   ## Only initialize the instance once
   else:
    if STATE.INSTANCE_NOW == 1:
     phase_now = phase.__text__
     manifest.clear()
     manifest.append(phase_now)
     ## Add to the current manifest
     PHASE_INSTANCE.append(manifest[0])
     STATE.INSTANCE_NOW = 1
    ## If a state object already exists, no updates to the phase
    else:
     PHASE_INSTANCE.append(manifest[0])
     manifest.clear()

  ## construct a phase
  construct()

class PhaseBroadcast:
 def __init__(self):
  def make():
   TEMP_INSTANCE_LAST.clear()
   with TemporaryFile('w+t') as f:
    f.write(manifest[0])
    INSTANCE_MESSAGE.append(manifest[0])
    f.seek(0)
    data = f.read()
    ## Provide the message in memory and in a temp instance
    TEMP_INSTANCE_LAST.append(f)
    print(data)
   f.close()
   INSTANCE_NOW = 0
  if STATE.INSTANCE_NOW == 1:
   pass
  else:
   manifest.clear()
  try:
   if INSTANCE_MESSAGE[0] == NEW_INSTANCE:
    make()
    INSTANCE_MESSAGE.clear()
   else:
    make()
  except IndexError:
   make()

def construct_current_phase():
  message = input("Message: ")
  manifest.append(message)
  PhaseBroadcast()

def update_current_phase():
  if STATE.INSTANCE_NOW == 1:
   manifest.clear()
   PhaseReceiver()
  else:
   STATE.INSTANCE_NOW = 1
   manifest.clear()
   PhaseReceiver()

def evaluate_phase():
 z = PHASE_INSTANCE
 print("manifest: "+str(manifest))
 print("INSTANCE_MESSAGE: "+str(INSTANCE_MESSAGE))
 print("PHASE_INSTANCE: "+str(z))

class PhaseTransmitter:
 """
 Usage: Run a conversation simulation or build deeper into the 
 prototype
 >>> from core_transmitter import PhaseTransmitter
 >>> PhaseTransmitter()
 """
 def __init__(self):
  ## action default instance link
  action = str('--- ADDED: SIMULATED PHASE MEMBER ---')

  ## define what happens when a function
  def register():
   """
   `register`: define what happens when a `phaseMember`
   class initiates
   """
   global r
   r = sim_id

  def defaultaction():
   global da
   da = print(action)

  ## Build a class to establish the basic phase
  class phaseMember:
   """
   phaseMember is a class that allows you to
   add and delete instance participants
   """
   def __init__(self):
    """
    phaseMember __init__ of the dynamic usermask
    allocation and selected instance name
    """
    self.data = defaultdict(set)
    register()

   def add(self, usermask, instancename):
    """
    phaseMember: add ->
    set the 'usermask' and 'instancename' based off of the
    dynamic allocation from 'usermask_[1-n]
    '"""
    self.data[usermask].add(instancename)
    defaultaction()

   def remove(self, usermask):
    """
    phaseMember: remove ->
    unset usermask_[1-n] from the phase based off of the
    dynamic attribute provided
    """
    del self.data[usermask]

  ## set the base instance for a resurrection
  allowed_member = phaseMember()

  def backup():
   global a
   a = allowed_member.data.copy()

  def clear():
   backup()
   allowed_member.data.clear()

  def resurrect():
   allowed_member.data = a

  ## Build a class for stateful interactions
  class populatePhase:
   def __init__(self):
    self.data = defaultdict(set)

   def inspect(self, instancename):
    pass

   def post(self, usermask, vectorContent):
    pass

   def interact(self, vectorId):
    pass

  ## Set the allowed instance type
  allowed_population = populatePhase()

  ## Build a simple redundant-making class
  ## This is on a timer, and every X seconds the phase is backed up to disk
  ## from memory
  class backupInterval:
   intervalPath = PATH_INSTANCE+DIRDATA+CURRENT_FULLES
   tempPath = PATH_INSTANCE+DIRDATA+TEMP_FULLES

  def __init__(self):
   self.data = defaultdict(set)

  def write():
   pass

  ## set the phase interval
  set_interval = backupInterval()

  class phase:
   __text__ = text_now

  ## Build a message_que
  message_que = phase.__text__
  manifest = []

  def clearmanifest():
   manifest.clear()

  def wrotetophase():
   with TemporaryFile('w+t') as f:
    f.write(message_que)
    f.seek(0)
    global tempdata
    tempdata = f.read()
    print(tempdata)
    f.truncate(0)
   f.close

  ## add it to the waiting manifest
  manifest.append(message_que)

  print('-----------------------------------------------')
  print('--- REGISTERING SIMULATION PHASE ---')
  print('-----------------------------------------------')
  print('--- Simulation Established with slug: ' + r)
  print('-----------------------------------------------')
  print('--- STARTING: SIMULATION MEMBER PHASE AFTER `phaseMember.add` ---')
  print('-----------------------------------------------')
  allowed_member.add(usermask_1, 'pablo')
  allowed_member.add(usermask_2, 'bandit')
  print('-----------------------------------------------')
  print('--- SUMMARY: SIMULATION DATA ---')
  print('-----------------------------------------------')
  print(allowed_member.data)
  allowed_member.remove(usermask_1)
  print('-----------------------------------------------')
  print('--- SUMMARY: SIMULATION DATA AFTER `phaseMember.remove`---')
  print('-----------------------------------------------')
  print(allowed_member.data)
  allowed_member.add(usermask_1, 'pablo')
  print('-----------------------------------------------')
  print('--- STARTING: SIMULATION MEMBER PHASE' \
   'AFTER RESTORING USERMASK WITH `phaseMember.add` ---')
  print('-----------------------------------------------')
  print(allowed_member.data)
  allowed_member.add(usermask_3, 'gemeni')
  allowed_member.add(usermask_4, 'grifter')
  allowed_member.add(usermask_5, 'anon')
  allowed_member.add(usermask_6, 'anon')
  print('-----------------------------------------------')
  print('--- SUMMARY: SIMULATION DATA ---')
  print('-----------------------------------------------')
  allowed_member.data
  ## dir(allowed_member.data)
  print('-----------------------------------------------')
  print('--- SUMMARY: DOCSTRING DATA ---')
  print('-----------------------------------------------')
  print(allowed_member.__doc__)
  print(allowed_member.__init__.__doc__)
  print(allowed_member.add.__doc__)
  print(allowed_member.remove.__doc__)
  print('-----------------------------------------------')
  print('--- SUMMARY: SIMULATION DATA ---')
  print('-----------------------------------------------')
  print(allowed_member.data)
  backup()
  clear()
  a
  print(allowed_member.data)
  print('-----------------------------------------------')
  resurrect()
  print('-----------------------------------------------')
  print(allowed_member.data)
  print('-----------------------------------------------')
  ## This is now a completed instance
  print(message_que)
  manifest
  print('-----------------------------------------------')
  wrotetophase()
  manifest
  print('-----------------------------------------------')
  wrotetophase()
  clearmanifest()
  manifest
  print('-----------------------------------------------')
  wrotetophase()
  manifest
  print('-----------------------------------------------')
  clearmanifest()
  manifest
  print('-----------------------------------------------')



Return HOME