Esempio n. 1
0
    def on_activate(self):
        """ Activate module.

            This method needs to set ip the CLR to Python binding and start Lightfield.
        """

        lfpath = os.environ['LIGHTFIELD_ROOT']
        lfaddinpath = os.path.join(os.environ['LIGHTFIELD_ROOT'], 'AddInViews')

        sys.path.append(lfpath)
        sys.path.append(lfaddinpath)
        ref1 = clr.AddReference('PrincetonInstruments.LightFieldViewV4')
        ref2 = clr.AddReference('PrincetonInstruments.LightField.AutomationV4')
        #print(dir(ref), '\n\n')
        #ref.LoadFrom(ref.Location)

        verbose = list(clr.ListAssemblies(True))
        short = list(clr.ListAssemblies(False))
        #for i in short:
        #        print('ASSEMBLY:', i)
        #for i in verbose:
        #    print('ASS:', i)

        #for i in ref2.Modules:
        #    print('ASS Module:', i)
        #for i in ref2.ExportedTypes:
        #    print('ASS Exported type:', i)
        try:
            for i in ref2.DefinedTypes:
                print('ASS Defined type:', i)
        except System.Reflection.ReflectionTypeLoadException as e:
            for i in e.LoaderExceptions:
                print('EXC:', i.Message)

        print('ASS Entry point:', ref2.EntryPoint)
        print('ASS is Dynamic:', ref2.IsDynamic)

        from PrincetonInstruments.LightField.Automation import Automation
        import PrincetonInstruments.LightField.AddIns as ai

        lst = col.List[System.String]()
        self.au = Automation(True, lst)
        self.app = self.au.LightFieldApplication
        self.exp = self.app.Experiment

        self.exp.ExperimentCompleted += EventHandler(
            self.setAcquisitionComplete)
        self.exp.ImageDataSetReceived += EventHandler(self.frameCallback)
        self.exp.SettingChanged += EventHandler(self.settingChangedCallback)

        self.app.UserInteractionManager.SuppressUserInteraction = True

        self.prevExperimentName = self.exp.Name
        print('Prev Exp', self.prevExperimentName)
        #self.getExperimentList()
        #self.openExperiment(name)
        self.lastframe = list()
Esempio n. 2
0
def _load_assemblies(amo_path=None, adomd_path=None):
    """
    Loads required assemblies, called after function definition.
    Might need to install SSAS client libraries:
    https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers

    Parameters
    ----------
    amo_path : str, default None
        The full path to the DLL file of the assembly for AMO. 
        Should end with '**Microsoft.AnalysisServices.Tabular.dll**'
        Example: C:/my/path/to/Microsoft.AnalysisServices.Tabular.dll
        If None, will use the default location on Windows.
    adomd_path : str, default None
        The full path to the DLL file of the assembly for ADOMD. 
        Should end with '**Microsoft.AnalysisServices.AdomdClient.dll**'
        Example: C:/my/path/to/Microsoft.AnalysisServices.AdomdClient.dll
        If None, will use the default location on Windows.
    """
    # Full path of .dll files
    root = Path(r"C:\Windows\Microsoft.NET\assembly\GAC_MSIL")
    # get latest version of libraries if multiple libraries are installed (max func)
    if amo_path is None:
        amo_path = str(
            max((root / "Microsoft.AnalysisServices.Tabular").iterdir()) /
            "Microsoft.AnalysisServices.Tabular.dll")
    if adomd_path is None:
        adomd_path = str(
            max((root / "Microsoft.AnalysisServices.AdomdClient").iterdir()) /
            "Microsoft.AnalysisServices.AdomdClient.dll")

    # load .Net assemblies
    logger.info("Loading .Net assemblies...")
    clr.AddReference("System")
    clr.AddReference("System.Data")
    clr.AddReference(amo_path)
    clr.AddReference(adomd_path)

    # Only after loaded .Net assemblies
    global System, DataTable, AMO, ADOMD

    import System
    from System.Data import DataTable
    import Microsoft.AnalysisServices.Tabular as AMO
    import Microsoft.AnalysisServices.AdomdClient as ADOMD

    logger.info("Successfully loaded these .Net assemblies: ")
    for a in clr.ListAssemblies(True):
        logger.info(a.split(",")[0])
Esempio n. 3
0
def _load_assemblies():
    '''Loads required assemblies, called after function definition.'''

    # Full path of .dll files, gets newest version if there are several folders
    amo_root = (r"C:\Windows\Microsoft.NET\assembly\GAC_MSIL"
                r"\Microsoft.AnalysisServices.Tabular")
    amo_folder = max(os.listdir(amo_root))
    amo_path = os.path.join(amo_root, amo_folder,
                            os.listdir(os.path.join(amo_root, amo_folder))[0])

    adomd_root = (r"C:\Windows\Microsoft.NET\assembly\GAC_MSIL"
                  r"\Microsoft.AnalysisServices.AdomdClient")
    adomd_folder = max(os.listdir(adomd_root))
    adomd_path = os.path.join(
        adomd_root, adomd_folder,
        os.listdir(os.path.join(adomd_root, adomd_folder))[0])

    # Check that file paths are valid
    assert os.path.isfile(amo_path), (
        'The filepath for the AMO dll is '
        'invalid , you passed the filepath: {}'.format(amo_path))
    assert os.path.isfile(adomd_path), (
        'The filepath for the ADOMD dll is '
        'invalid , you passed the filepath: {}'.format(adomd_path))

    # load .Net assemblies
    logger.info('Loading .Net assemblies...')
    clr.AddReference('System')
    clr.AddReference('System.Data')
    clr.AddReference(amo_path)
    clr.AddReference(adomd_path)

    # Only after loaded .Net assemblies
    global System, DataTable, AMO, ADOMD

    import System
    from System.Data import DataTable
    import Microsoft.AnalysisServices.Tabular as AMO
    import Microsoft.AnalysisServices.AdomdClient as ADOMD
    logger.info('Successfully loaded these .Net assemblies: ')

    # log each assembly loaded
    for a in clr.ListAssemblies(True):
        logger.debug(a.split(',')[0])
Esempio n. 4
0
from pyqtgraph import examples
import numpy as np
# examples.run()
# print(np.random.rand(2,4))
# ss=np.random.rand(100,100)
# kk=np.random.rand(100,100)
# hh=np.random.rand(100,100)
# np.savez("data.npz",npumpdata=ss,pumpdata=kk,od=hh)
# data=np.load("data.npz")
# # # print(data.files)
# # # print(data["od"])
# # # print(111)
# k=[5].extend([7])
# print(k)
import clr
import os
kk = clr.AddReference("Newport.DLS.CommandInterface")
kk = clr.ListAssemblies(True)
for i in kk:
    print(i)
print(kk)
Esempio n. 5
0
import clr;
import sys;
import os;

#clr.AddReference('MyThreeBodySimulator');

clr.AddReference("trypythonnet");
clr.AddReference('myPlanet');
clr.AddReference('System.Numerics.Vectors')

import System


for i in clr.ListAssemblies(False):
    print(i)

from System.Numerics.Vectors import *
from  tryofpythonnet import *
#from  MySimulatorOfThreeBody import *

Class1.hello("ppp")
#Class2.goodbye()

#import MySimulatorOfThreeBody;
print("success")