Multiple controllers accessing the same model object?!

Hi all,
I have a rather simple but really fundamental question. I am implementing an application which
communicates with a camera. My application main window is controlled by "MyController" class,
which has a "Camera" object "myCam" and a "capture" button. I would like to add "continuous
capture" functionality. I have subclassed NSButton(CameraCaptureButton class) and set in IB
the identity of the button. In the new class I have also the methods mouseUp/mouseDown which
are properly working. The problem now is how to send messages to "myCam" from CameraCaptureButton class. There is some sample code(mine is much more complex but I will extract only the part that I am interested in):
//CameraCaptureButton.h
#import "CameraCaptureButton.h"
#import "MyController.h"
@implementation CameraCaptureButton
- (id)initWithFrame:(NSRect)frame
self = [super initWithFrame:frame];
if (self)
// Initialization code here.
return self;
- (void) mouseDown:(NSEvent *)theEvent
//some pictures which are also set correctly
NSImage* buttonDown = [NSImage imageNamed:@"ReleaseFpsButtonDown.png"];
[self setImage:buttonDown];
NSLog(@"capture button down");
- (void) mouseUp:(NSEvent *)theEvent
//some pictures which are also set correctly
NSImage* button = [NSImage imageNamed:@"ReleaseFpsButtonOn.png"];
[self setImage:button];
NSLog(@"capture button up");
@end
//MyController.h
#import <Cocoa/Cocoa.h>
#import "Camera.h"
@interface MyController : NSWindowController
Camera* myCam;
Thank you in advance for any post!

The functionality is implemented and working. Ray if you read this: Thank you! Below I post the most important parts of my code, I will appreciate any comments or suggestions for better implementation( for example should I 'retain' the camera object in the setter method or is it already retain by the call in the header file?!)!
// MyController.h
#import "Camera.h"
@interface MyController : NSWindowController
/*some mode definitions*/
Camera* leCamera;
/*some more definitions*/
@property (nonatomic, retain) Camera *leCamera;
/*some more methods and properties*/
@end
// MyController.m
#import "MyController.h"
@implementation MyController
- (id)init
if (self = [super init])
Camera* cam = [[Camera alloc] init];
[self setLeCamera: cam];
...some more code...
return self;
-(void) setLeCamera: (Camera*) cam
leCamera = cam;
- (Camera*) leCamera
return leCamera;
@end
// CameraCaptureButton.m
#import "CameraCaptureButton.h"
#import "MyController.h"
#import "Camera.h"
@implementation CameraCaptureButton
- (id)initWithFrame:(NSRect)frame
self = [super initWithFrame:frame];
if (self)
return self;
- (void) mouseDown:(NSEvent *)theEvent
NSImage* buttonDown = [NSImage imageNamed:@"ReleaseFpsButtonDown.png"];
[self setImage:buttonDown];
MyController *delegate = [[NSApplication sharedApplication] delegate];
Camera* cam = delegate.leCamera;
int driveMode = [[cam camProp] driveMode];
if(driveMode == 1)
[cam releaseCam: 12];
else
[cam releaseCam: 0];
- (void) mouseUp:(NSEvent *)theEvent
NSImage* button = [NSImage imageNamed:@"ReleaseFpsButtonOn.png"];
[self setImage:button];
MyController *delegate = [[NSApplication sharedApplication] delegate];
Camera* cam = delegate.leCamera;
int driveMode = [[cam camProp] driveMode];
if(driveMode == 1)
[cam releaseCam: 13];
@end
Have fun!
Regards
- artOf...
P.S. the mouseUp/down events seem to track by default the mouse, so when I am over the
button and push it, it does as expected. Same for mouseUp, even if I hold the button pushed,
drag the mouse outside my application and then release it I get the mouseUp event which is
great I had so many problems in the .NET version with that

Similar Messages

  • Multiple DEVL_PROJECT_ID for the same model in CZ_DEVL_PROJECTS Table.

    Hi,
    Did anyone came across this issue!! I am triggering the config engine from back and and trying to pick up a model but it has multiple devl_project_id's. :(
    I could see multiple DEVL_PROJECT_ID for the same model in CZ_DEVL_PROJECTS Table. Apart from DEVL_PROJECT_ID and created_by_date every thing looks the same.
    Below are the 2 records the data from the table
    select * from CZ.CZ_DEVL_PROJECTS where product_key = '122:17056' and DEVL_PROJECT_ID in (12943,15321)
    DEVL_PROJECT_ID     NAME     ORIG_SYS_REF     CREATION_DATE     LAST_UPDATE_DATE     PERSISTENT_PROJECT_ID     MODEL_TYPE
    12943     ASI XXX MODEL(122 17056)     OPTIONAL:122:17056     12/18/2012 10:01     12/18/2012 10:01     11100     A
    PRODUCT_KEY     ORGANIZATION_ID     INVENTORY_ITEM_ID     BOM_CAPTION_RULE_ID     NONBOM_CAPTION_RULE_ID
    122:17056     122     17056     802     801
    15321     ASI XXX MODEL(122 17056)     OPTIONAL:122:17056     12/26/2012 23:10     12/26/2012 23:10     11100     A     
    122:17056     122     17056     802     801
    Thanks in advance,
    -vijay

    It can be possible to have multiple devl_project_id for the same model in cz_devl_projects Table.
    Case -1 : When you delete the existing model and re-import again.
    case 2:
    When you publish the model locally, it will create the same copy of the record with different devl_project_id, creation_date, last update_date etc..\
    You can see that for published records the last_updat_login, checkout_user will be null and for the original model, last_update_login,checkout_user (if model is locked) will not be null.
    -Murali
    Edited by: 907569 on Jan 8, 2013 10:55 AM

  • Multiple threads access the same method.

    Hello,
    I have been trying for a long time to find out multiple threads access the shared data.
    I have written a sample code, there I my intention is that method has to be accessed
    onlny one thread at a time., mean one thread finished the job, then next thread can
    access the shared source. But for this code I am not getting the desired out put what I want. But if I am using synchronized block I am getting the output. Please correct where I got mistake. Please see my code.
    public class TestThread implements Runnable {
         Shared r;
         public TestThread() {
              r = new Shared();
         public static void main(String args[]) {
              Thread t1 = new Thread(new TestThread());
              Thread t2 = new Thread(new TestThread());
              t1.setName("A");
              t2.setName("B");
              t1.start();
              t2.start();
          * (non-Javadoc)
          * @see java.lang.Runnable#run()
         @Override
         public void run() {
              // TODO Auto-generated method stub
              r.count();
    class Shared {
         public synchronized void count() {
              String name = Thread.currentThread().getName();
              System.out.println(name + ":accessed...");
              try {
                   for (int i = 0; i < 5; i++) {
                        System.out.println(name + ": " + i);
              } catch (Exception e) {
                   // TODO: handle exception
    }Thanks
    Bhanu lakshmi.

    It depends on what you synchronize. Non-static methods synchronize on the object, so if you're using several objects, you'll be able to call each from their own thread.
    Make your method synchronized or use only a single object and see the difference.

  • Prevent multiple users accessing the same form

    hi,
    i am working in forms
    i have a requirement like this
    if more than one user are using the same form and try to access the same record then the second user should not be able to do transaction
    he should be popped up with a msg saying that other user is working on it
    can any one suggest how to do this in my form
    thanks in advance
    selvaraj s

    That is pretty much exactly the way Forms works automatically.
    Two users can use the same form, and can even display the same data record. One of the users can make changes to the record -- Forms locks the row upon the FIRST keystroke in the first field the user begins to change.
    Once the row is locked, the second user is free to look at the record, and won't even know if another user has begun making changes. However, if second user tries to change even one field in the record, Forms pops up the message, "Could not reserve record (2 tries). Keep trying? Yes / No"
    There are also protections so if the first user actually changes the row and commits, then the second user tries to make a change. Forms will automatically detect whether changes were made, and if so, will undo the change and issue the message, "FRM-40654: Record has been updated by another user. Re-query to see change."
    The above automatic processing works very nicely. If it will not work for you, then what is it you need?

  • Multiple users accessing the same server.

    Ok here is my issue, about 2 months ago I started having issues with Filesharing on my 2012 Mac Mini running Lion server (current update). We have 3 users that VPN into our conpany network and usually access the same folder, 2 months ago they started conflicting with each other. When one VPNs into the network and connects to the server they are fine, if the second one connects to the network they are fine but if the second one tries to access the fileshare they knock the second one off the server. The first one's connection eventually hangs and they have to completely disconnect from the VPN. I am wondering if this was caused by a patch or if there is something else going on. I have tried to reboot the server and checked the logs for anything but I am not seeing what may be causing this. I have restarted the Filesharing in the Server app and still get the same problem, the users are connecting via local credentials to the server. I don't think it is a password issue since either user can log in and access as long as another user doesn't so I am not sure what the issue could be.
    any help appriciated,
    josh

    By 'standard record locking system' do you mean there is nothing I need to do programatically? No block level properties to change?
    So you are saying this is just the way it always works. So as soon as one of our call center agents opens a record all I have to do is create a pending update to any field?
    But won't another user be able to open the form and just query that record not knowing another user has it open?

  • Multiple User Accessing the same record issue

    I am planning to design an app where we have the following use case requirement.
    If a user who is logged into the system is accessing a record(plan in this case) anyone else who is logged into the system at the same time should be locked out of that same plan but should still be able to access other plans in the system. A plan has many things associated with it so the 2nd user should be locked out of everything associated to the plan being accessed by the first user.
    What is the best way to implement this at the application or the database level?
    Here are some options we have been bouncing around.
    1. When the first user logs in and accesses the first plan we lock the plan at the app level using a singleton class which has one and only one instance on the app server. The plan_id can be put as an entry into a hashtable which can be in the session and is created if one does not exist. When the 2nd user tries to access the same plan, since the plan_id is still in the hashtable he would be locked out. However we somehow need to timeout the first user after 30 mts of inactivity or so so that others can access the plan and are not locked out for ever if the first user walks away from his PC or does not close his browser, thus keeping his session alive indefinitely.
    2. In the database in the plan table we add a column for 'locked'. When the first entry is created in the plan table locked column is marked as 'yes' or 1 and when the user closes the browser we use some javascript to trigger an event which changes that 'yes' or 1 to 'no' or 0 thus unlocking the plan. However the big issue we see in this concept is that we will have to put a javascript onUnload method in all jsp pages in the app because the user could be anywhere in the app after starting his plan access after login.
    Conceptually the 2 options are the same but one is done at the app whereas the other is at the database level.
    Is there a better way to handle this scenario using transactions or some other technological option.
    Thanks

    Another solution involving no modification of the database structure:
    As soon as a user want to access a plan, try to UPDATE the plan record... if it fails, the record was locked
    by another user before. When the user has finished with the plan, you can COMMIT or ROLLBACK the changes, which will free the lock for other users.
    An advantage of this solution is that if program crashes unexpectedly, there will automatically be a ROLLBACK.
    Of course, you need a transaction for this... and perhaps more if you want to separate the 'locking transaction' (virtual update just for restricting access) from the 'operating transaction' (in which you will
    do the DB stuff: inserts, updates, deletes, etc.)
    Hope this helped,
    Regards.

  • Installing multiple instances accessing the same database

    Hi,
    I want to install two different instances of Oracle 10g in two different machines which will access the same database which will be stored in the shared storage.
    Is it possible to install them without installing RAC? The instances will be one active and the other passive, so the services will be up in one server and down in the other and the switching (shutting down one server and starting up the other) will be manual.
    Two servers will be running Linux and clustered in Linux level.
    Does Oracle offers this solution without installing Clusterware software?
    Thank you

    > The instances will be one active and the other passive, so the services will be up in one server and down in
    the other and the switching (shutting down one server and starting up the other) will be manual
    Missed this part as I was thinking proper cluster and RAC.
    This is neither. Yes, this can be done using two servers and shared storage.
    Is it a good idea? Not really. As this configuration does not provide redundancy at physical database level. You loose that storage.. bye-bye database. Does not matter whether you have a 100 backup servers that can be used.
    Thus the business reasons that you are trying to meet with this config have to be clarified and expectations determined.
    Separate servers using Data Guard will be a far more superior solution in many respects.

  • Multiple users accessing the same data in a global temp table

    I have a global temp table (GTT) defined with 'on commit preserve rows'. This table is accessed via a web page using ASP.NET. The application was designed so that every one that accessed the web page could only see their data in the GTT.
    We have just realized that the GTT doesn't appear to be empty as new web users use the application. I believe it has something to do with how ASP is connecting to the database. I only see one entry in the V$SESSION view even when multiple users are using the web page. I believe this single V$SESSION entry is causing only one GTT to be available at a time. Each user is inserting into / selecting out of the same GTT and their results are wrong.
    I'm the back end Oracle developer at this place and I'm having difficulty translating this issue to the front end ASP team. When this web page is accessed, I need it to start a new session, not reuse an existing session. I want to keep the same connection, but just start a new session... Now I'm losing it.. Like I said, I'm the back end guy and all this web/connection/pooling front end stuff is magic to me.
    The GTT isn't going to work unless we get new sessions. How do we do this?
    Thanks!

    DGS wrote:
    I have a global temp table (GTT) defined with 'on commit preserve rows'. This table is accessed via a web page using ASP.NET. The application was designed so that every one that accessed the web page could only see their data in the GTT.
    We have just realized that the GTT doesn't appear to be empty as new web users use the application. I believe it has something to do with how ASP is connecting to the database. I only see one entry in the V$SESSION view even when multiple users are using the web page. I believe this single V$SESSION entry is causing only one GTT to be available at a time. Each user is inserting into / selecting out of the same GTT and their results are wrong.
    I'm the back end Oracle developer at this place and I'm having difficulty translating this issue to the front end ASP team. When this web page is accessed, I need it to start a new session, not reuse an existing session. I want to keep the same connection, but just start a new session... Now I'm losing it.. Like I said, I'm the back end guy and all this web/connection/pooling front end stuff is magic to me.
    The GTT isn't going to work unless we get new sessions. How do we do this?
    Thanks!You may want to try changing your GTT to 'ON COMMIT DELETE ROWS' and have the .Net app use a transaction object.
    We had a similar problem and I found help in the following thread:
    Re: Global temp table problem w/ODP?
    All the best.

  • What happens when multiple users access the same servlet?

    Do the users share all the same resources? Or is a new process generated for each user? I have a servlet that builds a string to return to the user and I only have myself to test, so I can't really see what happens when many users access the servlet. Is there a possibility that the string will get screwed up, like when dealing with multiple threads, or do all the users get their own resources and I don't have to worry about that?

    huh? if you can point a test servlet at it, you can point a browser at it (even if the servlet does not serve html it will run)
    try pasting the servlet URL into a web browser
    refreshing multiple browsers repeatedly could provide a manual test

  • Problem with multiple threads accessing the same Image

    I'm trying to draw into one Image from multiple threads. It works fine for a while, but then suddenly, the image stops updating. Threads are still running but the image won't update. I'm using doublebuffering and threads are simply drawing counters into Image with different speed.
    It seems like the Image gets deadlocked or something. Anyone have any idea what's behind this behavior or perhaps better solution to do such thing.
    Any help will be appreciated.

    Sorry Kglad, I didn't mean to be rude. With "No coding
    errors" I meant the animation itself runs with no errors. I'm sure
    you could run the 20 instances with no freezing (that's why I put
    the post :) ) But I'm affraid it is an animation for a client, so I
    cannot distribute the code.
    Perhaps I didnt explain the situation clearly enough (in part
    because of my poor english...).-
    - By 20 instances I mean 20 separated embedded objects in the
    html
    - The animation is relatively simple. A turned on candle, in
    each cycle I calculate the next position of the flame (that
    oscilates from left to right). The flame is composed by 4
    concentric gradients. There is NO loops, only an 'onEnterFrame'
    function refreshing the flame each time.
    - It's true that I got plenty variables at the _root level.
    If that could be the problem, how can I workaround it?
    - It is my first time trying to embed so many objects at the
    same time too. No idea if the problem could be the way I embed the
    object from the html :(
    - The only thing I can guess is that when a cycle of one of
    the object is running, the other 19 objects must wait their turn.
    That would explain why the more instances I run, the worst results
    I get. In that case, I wonder if there's a way to run them in a
    kind of asynchronous mode, just guessing...
    Any other comment would be appreciated. Anyway, thanks a lot
    everybody for your colaboration.

  • Multiple Users accessing the same core set of queried data

    Hi. We have a small call center and we want to build an app where the users can query the same core set of data and use it to initiate calls to study participants. The trick is that they will also need to update each record with information from the call. So we need to stop two call center agents from potentially calling the same participant at the same time.
    Is there a good method or best practice for creating a app to do this? The concern is that multiple call center agents would be querying the screen with the same core set of records (for example, querying by 'Ready for Call' status). When a call is placed the agent will have a conversation with the participant and ultimately end up updating the record after about 10 minutes. So my question is whether there is a good way to keep multiple agents from working with the same record (e.g. calling the same participant simultaneously)?
    Right now it seems that Oracle will lock a record for update, but only after an agent has initiated a change to the record. This still leaves a window of opportunity for two or more agents to be calling the same participant at the same time.
    Any thoughts or ideas on this would be greatly appreciated. Thanks so much.

    By 'standard record locking system' do you mean there is nothing I need to do programatically? No block level properties to change?
    So you are saying this is just the way it always works. So as soon as one of our call center agents opens a record all I have to do is create a pending update to any field?
    But won't another user be able to open the form and just query that record not knowing another user has it open?

  • Please help! Multiple users accessing the same data sets

    Hi all,
    Can anyone provide a bit of insight in to a question I have?
    We have two users that require to see the same set of data in the BPC Excel interface at the same time. The information is employees and date.
    User 1 would like to see All Employee SignedData for 1 month, and User 2 would like to see just a slice of the Employees for 1 month.
    If both of the Users are logged in at the same time, what will happen in terms of SAP 'locking' the data set? I am aware of Data Access Profiles to restrict their access to particular Master Data but there will be the requirement for users to see (maybe just in read-only), data that is shared between both Users.
    Will it throw up an error or can I make it so that users have 'read only' access?
    Any advice would be very much appreciated!
    Nick

    Hi Nick,
    No issue with that at all.
    They can even both have write access. If they try to update the exact same record at the same time BPC will just keep writing Delta records.
    User A enters 10
    User B enters 20
    User A refreshes and will get 20
    User B refreshes and also gets 20

  • Can multiple Macs access the same firewire volume simultaneously?

    I have a firewire drive and hub, and two Mac Minis. I would like to use this hardware to build an Oracle 10g Real Application Cluster (RAC). To do this, both Macs would have to be able to read/write blocks on the same volume on the firewire drive (Oracle prevents collisions). Newer Linux kernels have support for doing this. It seems that the Mac OS X Server 10.3.4 that I am using blocks at the volume level by node. It would seem to preclude my using this hardware unless I devote another machine to being an NFS server for the shared storage. I'm looking for possible kernel tricks to get this to work.
    Jeremiah
    Mac Mini   Mac OS X (10.3.4)  

    According to Oracle's white paper on RAC:
    The type of disk storage used can be network attached storage (NAS), storage area network (SAN), or SCSI disk.
    It does go on to say:
    Alternatively Oracle supports the use of raw devices and some cluster file systems such as Oracle Cluster File System (OCFS) which is available on Windows, Linux and Solaris
    I suppose if Oracle is taking over the raw device, support might be possible, but OCFS is not available for Mac OS X.

  • Multiple classes accessing the same DLL???

    This behaviour is completely unacceptable.
    Let's visualise my app:
    There a 2 java classes:
         ClassA:
              public String[] getPaths(){
                   return getNativePaths();
              public native String[] getNativePaths();
              static{
                   System.loadLibrary("mylib");
              }     ClassB:
              public void setPaths(String[] paths){
                   setNativePaths(paths);
              public native void setNativePaths(String[] paths);
              static{
                   System.loadLibrary("mylib");
              }     MainClass:
              public void testA(){
                   ClassB clsB=new ClassB();
                   String paths[]={"c:\\test.txt"};
                   clsB.setPaths(paths);
              public void testB(){
                   ClassA clsA=new ClassA();
                   String paths[]=clsA.getPaths();
              public void testC(){
                   ClassA clsA=new ClassA();
                   String[] paths=clsA.getPaths();
                   clsA=null;
                   ClassB clsB=new ClassB();
                   clsB.setPaths(paths);
              }Method testA and testB in MainClass don't pose any problems, they work fine. :)
    But when calling testC, I get this:
    java.lang.UnsatisfiedLinkError: no mylib in java.library.path
         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
         at java.lang.Runtime.loadLibrary0(Runtime.java:788)
         at java.lang.System.loadLibrary(System.java:832)
         ...ClassA and ClassB both work good if used separately (another thread). But if we call one after another (same thread), an exception is thrown.
    So, what's the problem here?
    Is it the return of a string array?

    1 remark:
    If I do this:
        ClassA clsA=new ClassA();
        ClassB clsB=new ClassB();
        clsB.setPaths(clsA.getPaths());This works, but if you call the dll again after this, you'll get the same exception over and over again.
    I think it has something to do with the release of strings (cause there isn't any).
    My native code that returns an array of Strings:
        jobjectArray strArray=null;
        strArray=env->NewObjectArray(nSize,env->FindClass("java/lang/String"),env->NewStringUTF(""));
        // loop
        env->SetObjectArrayElement(strArray,nCount,env->NewStringUTF(dlg->GetNextPathName(pos)));
        nCount++;
        return strArray;

  • Multiple iTunes accessing the same songs on local network??

    Hello all,
    I have imported all of our CD's into itunes on my computer. I would like for my wife and children to be able to access these songs and create their own playlists on their own computers from these songs. The kids have Windows Vista, and my wife, like I has an iMac.
    Is this possible?? If so are there any copywrite issues??
    Thanks in advance

    Yes, there is a way to share music across accounts on a Mac. First, you have to enable multiple logins (the Apple support person helped me with this).
    Then each person has to allow sharing in their itunes applications.
    Then, for one person to see and use another's music, that person has to be logged in and itunes has to be running in their instance, even though that instance is not active.
    Good luck.

Maybe you are looking for

  • To use a new ipod nano it says I need itunes 10.7 but I am using an imac with10.5.8 and it will not let me download the latest...what do I need to do?

    I am trying to hook up my daughters new ipod nano but when I plug it into my imac it says I need the latest version of itunes but it says my imac version 10.5.8 is not compatable (late enough)version...please help as to what I need to do?

  • Failure: "gnrclist.cpp" after a DLL call

    Forum: Since adding dll calls in a VI, LabVIEW is frequently crashing, both during VI execution and after exiting the application. Generally, what issues need to be considered when making successful dll calls (using the "call library function"). Jord

  • Number of CAL for my network

    how do I know how many CAL I have in my windows AD and how many I need to get? my AD is windows 2008 R2. I have abt 350 windows desktops/laptops. We hava a new office to setup which may require 20-30 new desktops. my boss is worried that we may run o

  • Typing and copy/paste in Hebrew

    Hi everyone. First time poster, so be gentle please. :-) So I am using CS5.1 and I have working on a project where I am recieving text in Hebrew. However, whenever I try to copy/paste the text, it flips the text around, like everything was typed in b

  • Premiere Pro CC crashing after opening autosave project

    PP CC crashes quite often. Working since weeks on a 60-minute-documentary with mixed footage (4K XAVC / Canon XF / XDcam HD 422). Because of the many crashes (5-10 per day) I´ve have to reopen / restore many times autosave-projects. Not a good idea: